williamr@2: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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 williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __MMSVSTOREMANAGER_H__ williamr@2: #define __MMSVSTOREMANAGER_H__ williamr@2: williamr@2: #include williamr@2: williamr@2: /** williamr@2: Provides the File Access mechanism to the files that are stored in the message server's williamr@2: data cage in a secure manner. Presents a common interface to message store file access williamr@2: regardless of the process that its running in. williamr@2: For instance, when the File Access APIs are used on the client-side process, the implementation williamr@2: uses secure IPC calls to the message server that includes capability policing, however, williamr@2: when the same API is used on the server-side, the implementation has direct access to williamr@2: the file in the message store. williamr@2: williamr@2: @internalTechnology williamr@2: */ williamr@2: class MMsvStoreManager williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Allows clients to create a new empty file and allows clients to stream data to it. williamr@2: williamr@2: Creates a new attachment file in the message store for the message entry specified by the aEntryId williamr@2: parameter. The attachment filename is set to the filename indicated by the aFilename parameter. williamr@2: The empty attachment file is passed back to the client using an opened file handle to the file in the message store. williamr@2: williamr@2: @param aEntryId The entry for which an attachment needs to be created in the message store williamr@2: @param aFilename The name of the attachment file to be created williamr@2: @param aFile On return, The created file handle for the attachment file.The ownership is transferred . The caller must close the file handle. williamr@2: @leave KErrAlreadyexists, if the file with the same name already existed the directory. williamr@2: */ williamr@2: virtual TBool CreateAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)=0; williamr@2: williamr@2: /** williamr@2: Allows clients to replace an existing attachment file and allows clients to stream data to it. williamr@2: williamr@2: Replaces an existing attachment file in the message store for the message entry specified by the aEntryId williamr@2: parameter. The attachment filename is set to the filename indicated by the aFilename parameter. williamr@2: If an attachment with the supplied name does not exist, a new file is created. The empty attachment williamr@2: file is passed back to the client using an opened file handle to the file in the message store. williamr@2: williamr@2: @param aEntryId The entry for which an attachment needs to be created in the message store williamr@2: @param aFilename The name of the attachment file to be created williamr@2: @param aFile On return, The created file handle for the attachment file.The ownership is transferred . The caller must close the file handle. williamr@2: */ williamr@2: virtual void ReplaceAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)=0; williamr@2: williamr@2: /** williamr@2: Allows clients to view attachment files. williamr@2: williamr@2: Opens an existing attachment file in the message associated with the message williamr@2: entry specified by the aEntryId parameter. The attachment is identified by williamr@2: the file path specified by the aFilePath parameter. The attachment file is williamr@2: returned as a read-only file handle to the file in the message store. williamr@2: williamr@2: @param aEntryId The entry whose attachment needs to be opened/read from the message store williamr@2: @param aFilePath The name and path of the attachment file to be opened williamr@2: @param aFile On return, The opened file handle for the attachment file.The ownership is transferred . The caller must close the file handle. williamr@2: */ williamr@2: virtual void OpenAttachmentL(TMsvId aEntryId, const TDesC& aFilePath, RFile& aFile)=0; williamr@2: williamr@2: /** williamr@2: Allows clients to open an attachment file for writing. williamr@2: williamr@2: Opens an existing attachment file in the message associated with the message williamr@2: entry specified by the aEntryId parameter. The attachment is identified by williamr@2: the file path specified by the aFilePath parameter. The attachment file is williamr@2: returned as a read/write file handle to the file in the message store. williamr@2: williamr@2: @param aEntryId The entry whose attachment needs to be opened/read from the message store williamr@2: @param aFilePath The name and path of the attachment file to be opened williamr@2: @param aFile On return, The opened file handle for the attachment file.The ownership is transferred . The caller must close the file handle. williamr@2: */ williamr@2: virtual void OpenAttachmentForWriteL(TMsvId aEntryId, const TDesC& aFilePath, RFile& aFile)=0; williamr@2: williamr@2: williamr@2: /** williamr@2: Allow clients to delete existing attachment files. williamr@2: williamr@2: Deletes an existing attachment file in the message store associated with the williamr@2: message entry specified by the aEntryId parameter. The attachment is williamr@2: identified by the file path specified by the aFilePath parameter. williamr@2: williamr@2: @param aEntryId The entry whose attachment needs to be deleted from the message store williamr@2: @param aFilePath The name and path of the attachment file to be deleted williamr@2: @return KErrNone if successful, otherwise any of the system wide error codes. williamr@2: */ williamr@2: virtual TInt DeleteAttachment(TMsvId aEntryId, const TDesC& aFilePath)=0; williamr@2: williamr@2: /** williamr@2: Renames an existing attachment file. williamr@2: williamr@2: Renames an existing attachment file in the message store associated with the williamr@2: message entry specified by the aEntryId parameter. The attachment is williamr@2: identified by the file path specified by the aOldFilePath parameter and renamed to williamr@2: the name supplied in the aNewName paramter. williamr@2: williamr@2: @param aEntryId The entry whose attachment needs to be renamed from the message store williamr@2: @param aOldFilePath The name and path of the attachment file to be renamed. williamr@2: @param aNewName The new name of the attachment file. williamr@2: @return KErrNone if successful, otherwise any of the system wide error codes. williamr@2: */ williamr@2: virtual TInt RenameAttachment(TMsvId aEntryId, const TDesC& aOldFilePath, const TDesC& aNewName) = 0; williamr@2: williamr@2: /** williamr@2: Check if an attachment file with the given path and name already exists. williamr@2: williamr@2: @param aFilePath The full path specification of the file. williamr@2: @return ETrue if file exists, otherwise EFalse. williamr@2: */ williamr@2: virtual TBool FileExistsL(const TDesC& aFilePath)=0; williamr@2: williamr@2: /** williamr@2: Queries the message server for the file path where attachments are stored for the williamr@2: a particular message entry. williamr@2: williamr@2: @param aEntryId The message entry for which the attachment path is required. williamr@2: @param aFilePath On return, this will be set to the file path where the attachment should be stored. williamr@2: */ williamr@2: virtual void AttachmentFilePathL(TMsvId aEntryId, TDes& aFilePath) = 0; williamr@2: williamr@2: // To support CMsvStore to provide message store file management. williamr@2: /** williamr@2: Allows the message store classes to read the store file for a particular message entry. williamr@2: williamr@2: Opens a message store file associated with the message entry specified by the aEntryId parameter. williamr@2: This method returns an open read-only file handle to the message store file. williamr@2: williamr@2: @param aEntryId The entry whose store needs to be opened/read williamr@2: @param aFile On return, The opened file hanlde to the store . The ownership is transferred . The caller must close the file handle. williamr@2: @leave KErrNotFound if file is not found else any of the system wide errors williamr@2: */ williamr@2: virtual TInt OpenFileStoreForRead(TMsvId aEntryId, RFile& aFile)=0; williamr@2: williamr@2: /** williamr@2: Opens a temporary store file associated with the message entry specified by the aEntryId parameter. williamr@2: This method returns an open read-write file handle with an exclusive share to the temporary store file. williamr@2: The temporary store file is defined as \.new. Data can be streamed to the temporary store file. williamr@2: It is expected that once the temporary store file has been written to and then closed, a call to williamr@2: ReplaceFileStoreL is required to replace the old store file with this temporary one. williamr@2: williamr@2: Along with ReplaceFileStoreL, this method allows the message store classes to write data williamr@2: to the store file for a particular message entry. williamr@2: williamr@2: @param aEntryId The entry whose store needs to be opened/read williamr@2: @param aFile On return, The opened file hanlde to the store . The ownership is transferred . The caller must close the file handle. williamr@2: */ williamr@2: virtual void OpenTempStoreFileL(TMsvId aEntryId, RFile& aFile)=0; williamr@2: williamr@2: /** williamr@2: Replaces the current store file with the temporary store file, created from OpenTempStoreFileL, williamr@2: for the message entry as specified by the aEntryId parameter. The method replaces the store file with williamr@2: the temporary file () and if successful, will then delete the temporary store file. williamr@2: This method assumes that the temporary file exists, otherwise a KErrNotFound error occurs. williamr@2: williamr@2: Along with OpenTempStoreFileL, this method allows the message store classes to write data to the store williamr@2: file for a particular message entry. williamr@2: williamr@2: @param aEntryId The entry whose store needs to be replaced/overwritten williamr@2: */ williamr@2: virtual void ReplaceFileStoreL(TMsvId aEntryId)=0; williamr@2: williamr@2: /** williamr@2: Deletes the store file associated with the message entry as specified by the aEntryId. williamr@2: Also attempts to delete the temporary store file if one exists. williamr@2: williamr@2: @param aEntryId The entry whose store needs to be deleted williamr@2: */ williamr@2: virtual void DeleteFileStoreL(TMsvId aEntryId)=0; williamr@2: williamr@2: /** williamr@2: Queries the message server to check if a store file exists for the message entry specified by williamr@2: the aEntryId parameter. williamr@2: williamr@2: @param aEntryId The entry for whom the check for existance of store is being done williamr@2: @return ETrue if the store exists else EFalse williamr@2: */ williamr@2: virtual TBool FileStoreExistsL(TMsvId aEntryId) const=0; williamr@2: williamr@2: /** williamr@2: Creates an Attachment using a ShareProtected RFs.Used in the case when a message contains a DRM attachment williamr@2: williamr@2: @param aEntryId The entry for which an attachment needs to be created in the message store williamr@2: @param aFilename The name of the attachment file to be created williamr@2: @param aFile On return, The created file handle for the attachment file.The ownership is transferred . The caller must close the file handle. williamr@2: @leave KErrAlreadyexists, if the file with the same name already existed the directory. williamr@2: */ williamr@2: virtual TBool CreateShareProtectedAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile) = 0; williamr@2: williamr@2: /** williamr@2: Gets the path of the bodytext file related to a message in the message store for the message id passed to it. williamr@2: @param aBodyTextId The Id of the bodytext for which the path is required in the message store williamr@2: @param aFilename On return, The path of the file corresponding to the message Id passed. williamr@2: @leave KErrAlreadyexists, if the file with the same name already existed the directory. williamr@2: */ williamr@2: virtual void BodyTextFilePathL(TMsvId aMessageId, TDes& aFilepath) = 0; williamr@2: williamr@2: /** williamr@2: Allows the message store classes to read the store file for a particular message entry. williamr@2: williamr@2: Opens a message store file associated with the message entry specified by the aFilepath parameter. williamr@2: This method returns an open read-only file handle to the message store file. williamr@2: williamr@2: @param aFile On return, The opened file hanlde to the store . The ownership is transferred . The caller must close the file handle. williamr@2: @param aBodyTextId The Id of the bodytext. williamr@2: @param aFilepath The path of the file that needs to be opened/read williamr@2: @leave KErrNotFound if file is not found else any of the system wide errors williamr@2: */ williamr@2: virtual void OpenBodyTextFileForReadL(RFile& aFile, TMsvId aBodyTextId, const TDesC& aFilePath) = 0; williamr@2: williamr@2: /** williamr@2: Allows the message store classes to create the store file for a particular message entry. williamr@2: williamr@2: Creates a message store file associated with the message entry specified by the aFilepath parameter. williamr@2: This method returns an open read-write file handle to the message store file. williamr@2: williamr@2: @param aFile On return, The opened file hanlde to the store . The ownership is transferred . The caller must close the file handle. williamr@2: @param aBodyTextId The Id of the bodytext. williamr@2: @leave one of the other system-wide error codes. williamr@2: */ williamr@2: virtual void CreatePlainTextFileL(RFile& aFile, TMsvId aBodyTextId) = 0; williamr@2: williamr@2: /** williamr@2: Deletes the store file associated with the message entry as specified by aFilepath. williamr@2: williamr@2: @param aBodyTextId The Id of the bodytext. williamr@2: @leave KErrNotFound if file is not found else any of the system wide errors williamr@2: */ williamr@2: virtual void DeletePlainTextFileL(TMsvId aBodyTextId) = 0; williamr@2: williamr@2: /** williamr@2: Replaces the bodytext file associated with the message specified by aEntryId. williamr@2: @param aBodyTextId The Id of the bodytext. williamr@2: @leave KErrNotFound if file is not found else any of the system wide errors williamr@2: */ williamr@2: virtual void ReplacePlainTextFileL(TMsvId aBodyTextId) = 0; williamr@2: }; williamr@2: williamr@2: #endif // __MMSVSTOREMANAGER_H__