mmsengine/mmsmessage/inc/mmsentrywrapper.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2003-2007 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:  
       
    15 *     Entry wrapper class mixin interface definition
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef MMSENTRYWRAPPER_H
       
    21 #define MMSENTRYWRAPPER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include    <e32base.h>
       
    25 #include    <msvids.h>
       
    26 #include    <cmsvattachment.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 // FUNCTION PROTOTYPES
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CMmsHeaders;
       
    38 class CMsvMimeHeaders;
       
    39 class MMmsEntry;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44 *  Mixin class for entry wrapper that CMmsEncode and CMmsDecode need
       
    45 */
       
    46 class MMmsEntryWrapper
       
    47     {
       
    48     public:  // Virtual functions
       
    49     
       
    50         /**
       
    51         * Provide an edit store for editing messages
       
    52         * Ownership of the store is transferred. Caller must delete the store
       
    53         * @return CMsvStore* if successful, leaves if unsuccessful
       
    54         */
       
    55         virtual CMsvStore* EditStoreL() = 0;
       
    56 
       
    57         /**
       
    58         * provide a read store for editing messages
       
    59         * Ownership of the store is transferred. Caller must delete the store
       
    60         * @return CMsvStore* if successful, leaves if unsuccessful
       
    61         */
       
    62         virtual CMsvStore* ReadStoreL() = 0;
       
    63 
       
    64         /**
       
    65         * reads index entry contents from current entry
       
    66         * @param TMsvEntry reference to entry to be filled with data
       
    67         * @return error code, KErrNone if successful
       
    68         */
       
    69         virtual TInt GetIndexEntry( TMsvEntry& aTMsvEntry ) = 0;
       
    70        
       
    71         /**
       
    72         * stores index entry contents to current entry
       
    73         * @param TMsvEntry reference to entry to be written to disk
       
    74         * @return error code KErrNone, if successful
       
    75         */
       
    76         virtual TInt ChangeIndexEntry( TMsvEntry& aTMsvEntry ) = 0;
       
    77 
       
    78         /**
       
    79         * Sets context to specified message entry
       
    80         * @param aId ID of the new message entry.
       
    81         * @return error code, KErrNone if successful
       
    82         */
       
    83         virtual TInt SetCurrentEntry( TMsvId aEntryId ) = 0;
       
    84 
       
    85         /**
       
    86         * returns total size of all attachments including mime headers
       
    87         * and binary attachment data. Linked attachments are included
       
    88         * This function is needed to allocate the encoding buffer.
       
    89         * @param aStore Read store for the message entry
       
    90         * @return combined size of all attachments, including linked attachments
       
    91         */
       
    92         virtual TInt AttachmentsSizeL( CMsvStore& aStore ) = 0;
       
    93 
       
    94         /**
       
    95         * Check if disk space is below critical level when storing data.
       
    96         * @param aDataSize amount of data to be added. If aDataSize == 0,
       
    97         *     returns info if disk space is already below critical level.
       
    98         * @return error code KErrDiskFull if data does not fit,
       
    99         *     KErrNone if data fits.
       
   100         *     May return some other error code if appropriate.
       
   101         *     KErrNone always means it is all right to save the data.
       
   102         */
       
   103         virtual TInt DiskSpaceBelowCriticalLevelL( TInt aDataSize ) = 0;
       
   104 
       
   105         /**
       
   106         * Store CMmsHeaders to message store for main message entry.
       
   107         * @param aMmsHeaders headers to store.
       
   108         * @param aStore store to be used. If not given, function gets and commits store
       
   109         * @return error code if not successful, KErrNone if successful.
       
   110         */
       
   111         virtual TInt StoreMmsHeadersL( CMmsHeaders& aMmsHeaders, CMsvStore* aStore ) = 0;
       
   112 
       
   113         /**
       
   114         * Restore CMmsHeaders from message store for main message entry.
       
   115         * @param aMmsHeaders headers to restore.
       
   116         * @param aStore store to be used. If not given, function gets and closes store
       
   117         * Leaves if cannot restore headers.
       
   118         */
       
   119         virtual void RestoreMmsHeadersL( CMmsHeaders& aMmsHeaders, CMsvStore* aStore  ) = 0;
       
   120         
       
   121         /**
       
   122         * Create attachment, save data to file and save MIME headers.
       
   123         *     Must check first if enough disk space.
       
   124         *     DRM handling is done here if needed.
       
   125         *     Return code tells if whole attachment was removed.
       
   126         *     This is the one-shot function that does everything:
       
   127         *     Creates attachent, opens file, writes data, flushes it,
       
   128         *     closes file, saves MIME headers.
       
   129         *     Caller must commit and close store
       
   130         * @param aStore edit store for current entry
       
   131         * @param aFileName Suggested filename.
       
   132         * @param aAttachmentData Pointer to the attachment binary data.
       
   133         * @param aMimeHeaders Mime header structure to be saved.
       
   134         * @param aAttachment id of the newly created attachment if successful
       
   135         * @param aAttachmentSize size of the attachment binary data + mime headers
       
   136         * @param aDRMFlags structure where DRM flags are collected.
       
   137         *     These flags will ultimately be collected together for all
       
   138         *     attachments and stored into iMtmData1 of the parent entry.
       
   139         *     Therefore the function must only OR new flags into the structure
       
   140         *     and must not change any other bits (the same value may be reused
       
   141         *     for all attachments collecting the flags together).
       
   142         * @return Error code must indicate if attachment was removed (DRM) so that
       
   143         *     the first attachment id may be adjusted. (Decode must keep track
       
   144         *     of the first attachment in case root is not specified for
       
   145         *     multipart/related structure.
       
   146         *     KErrNone = All well.
       
   147         *     KDRMRemoved = all well otherwise, but DRM attachment was removed,
       
   148         *         and first attachment id must be adjusted accordingly.
       
   149         *     Some other error code means a more serious error.
       
   150         */
       
   151         virtual TInt CreateFileAttachmentL(
       
   152             CMsvStore& aStore,
       
   153             const TDesC& aFileName,
       
   154             const TPtrC8& aAttachmentData,
       
   155             CMsvMimeHeaders& aMimeHeaders,
       
   156             TMsvAttachmentId& aAttachment,
       
   157             TInt& aAttachmentSize,
       
   158             TInt32& aDRMFlags) = 0;
       
   159 
       
   160         /**
       
   161         * Deletes a message store entry.
       
   162         * @param aEntryIndex is the index of the entry, which will be deleted. 
       
   163         * If the Entry has children, all children are destroyed too.
       
   164         * @return error code if not successful, KErrNone if successful.
       
   165         */
       
   166         virtual TInt DeleteEntry( TMsvId aEntryIndex ) = 0;
       
   167 
       
   168         /**
       
   169         * Check if aFileName would form a valid filename.
       
   170         * Cannot use path because absolute path is not known. Only filename is checked
       
   171         * @param aFileName suggestion of a filename.
       
   172         * @return ETrue if filename is valid, EFalse if not.
       
   173         */
       
   174         virtual TBool IsValidFilename(
       
   175             const TPtrC& aFileName ) = 0;
       
   176 
       
   177         /**
       
   178         * Read the decoding flag from the service entry.
       
   179         *     (Info stored in MMS service entry)
       
   180         * @return ETrue = Log add details while decoding
       
   181         *     EFalse = Don't log details.
       
   182         */
       
   183         virtual TBool GetDecodingFlag() = 0;
       
   184 
       
   185         /**
       
   186         * Read the dump flag from the service entry.
       
   187         *     The dump flag tells if all incoming messages are dumped to a file.
       
   188         * @return ETrue = dump binary message to file while decoding
       
   189         *     EFalse = No binary dump wanted
       
   190         */
       
   191         virtual TBool GetDumpFlag() = 0;
       
   192         
       
   193         /**
       
   194         * Create Empty attachment file and save Mime headers.
       
   195         *     DRM check is done here.
       
   196         *     This function is the initialization function for chunked
       
   197         *         attachment handling.
       
   198         *     This function creates attachent, opens file, and saves MIME headers.
       
   199         *
       
   200         * @since v3.1
       
   201         * @param aStore edit store for current message entry
       
   202         *      Caller must keep store open until FinalizeAttachmentL has been called.
       
   203         * @param aFileName Suggested filename.
       
   204         * @param aMimeHeaders Mime header structure to be saved.
       
   205         * @param aAttachment id of the newly created attachment if successful
       
   206         */
       
   207         virtual void CreateEmptyFileAttachmentL(
       
   208             CMsvStore& aStore,
       
   209             const TDesC& aFileName,
       
   210             CMsvMimeHeaders& aMimeHeaders,
       
   211             TMsvAttachmentId& aAttachment) = 0;
       
   212             
       
   213         /**
       
   214         * Write attachment data into file.
       
   215         * Call DRM handler if needed.
       
   216         *
       
   217         * @since v3.1
       
   218         *
       
   219         * @param aAttachmentData Pointer to the attachment binary data.
       
   220         * @param aDRMFlags structure where DRM flags are collected.
       
   221         *     These flags will ultimately be collected together for all
       
   222         *     attachments and stored into iMtmData1 of the parent entry.
       
   223         *     Therefore the function must only OR new flags into the structure
       
   224         *     and must not change any other bits (the same value may be reused
       
   225         *     for all attachments collecting the flags together).
       
   226         * @return Error code must indicate if attachment was removed (DRM) so that
       
   227         *     KErrNone = All well.
       
   228         *     KDRMRemoved = all well otherwise, but DRM attachment was removed,
       
   229         *         and first attachment id must be adjusted accordingly.
       
   230         *     Some other error code means an error.
       
   231         * Leaves if memory runs out
       
   232         */
       
   233         virtual TInt ProcessAttachmentDataL(
       
   234             const TPtrC8& aAttachmentData,
       
   235             TInt32& aDRMFlags ) = 0;
       
   236         
       
   237         /**
       
   238         * Finalize the attachment.
       
   239         * Flush buffers and close file, calculate total size.
       
   240         * Caller must commit the store after this
       
   241         *
       
   242         * @since v3.1
       
   243         *
       
   244         * @param aStore edit store for current entry
       
   245         * @param aAttachmentSize size of the attachment binary data + mime headers
       
   246         * @param aDRMFlags structure where DRM flags are collected.
       
   247         *     These flags will ultimately be collected together for all
       
   248         *     attachments and stored into iMtmData1 of the parent entry.
       
   249         *     Therefore the function must only OR new flags into the structure
       
   250         *     and must not change any other bits (the same value may be reused
       
   251         *     for all attachments collecting the flags together).
       
   252         * @return Error code must indicate if attachment was removed (DRM) so that
       
   253         *     KErrNone = All well.
       
   254         *     KDRMRemoved = all well otherwise, but DRM attachment was removed,
       
   255         *         and first attachment id must be adjusted accordingly.
       
   256         *     Some other error code means an error.
       
   257         * Leaves if memory runs out
       
   258         */
       
   259         virtual TInt FinalizeAttachmentL(
       
   260             CMsvStore& aStore,
       
   261             TInt& aAttachmentSize,
       
   262             TInt32& aDRMFlags ) = 0;
       
   263 
       
   264 
       
   265     };
       
   266 
       
   267 #endif      // MMSENTRYWRAPPER_H
       
   268             
       
   269 // End of File