mmsengine/mmscodec/inc/mmsencode.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 - 2009 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 *     Binary encoding of a multimedia message
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CMMSENCODE_H
       
    22 #define CMMSENCODE_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <mentact.h>
       
    26 #include <badesca.h>
       
    27 #include <cmsvattachment.h>
       
    28 
       
    29 #include "mmsconst.h" // needed for TMmsRecipients
       
    30 #include "mmsservercommon.h" // needed for logging flag definition
       
    31 #include "mmscodecdatasupplier.h"
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // MACROS
       
    36 
       
    37 // DATA TYPES
       
    38 
       
    39 // FUNCTION PROTOTYPES
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class RBufWriteStream;
       
    43 class CMmsHeaders;
       
    44 class CMsvMimeHeaders;
       
    45 class MMmsEntryWrapper;
       
    46 class MMmsEntry;
       
    47 class CMsgTextUtils;
       
    48 
       
    49 // CLASS DECLARATION
       
    50 
       
    51 /**
       
    52 * Binary encoding of a multimedia message.
       
    53 *
       
    54 * @lib mmscodec.lib
       
    55 * @since v2.1
       
    56 */
       
    57 class CMmsEncode :public CMsgActive, public MMmsCodecDataSupplier
       
    58     {
       
    59 public:
       
    60     
       
    61     /**
       
    62      * @param aFs file system handle.
       
    63      */
       
    64     IMPORT_C static CMmsEncode* NewL( RFs& aFs );
       
    65     
       
    66     virtual ~CMmsEncode();
       
    67 
       
    68 public: // New functions
       
    69     
       
    70     /**
       
    71      * Start the state machine for encoding a message with headers and data.
       
    72      *
       
    73      * @param aEntryWrapper mixin for handling all message entry access
       
    74      * @param aMmsHeaders reference to CMmsHeaders class.
       
    75      * @param aEncodeBuffer buffer to hold the encoded data,
       
    76      * @param aStatus status of calling active object
       
    77      */
       
    78     IMPORT_C void StartL(
       
    79         MMmsEntryWrapper& aEntryWrapper,
       
    80         CMmsHeaders& aMmsHeaders,
       
    81         CBufFlat& aEncodeBuffer,
       
    82         TRequestStatus& aStatus );
       
    83 
       
    84     /**
       
    85      * Encode headers only.
       
    86      *
       
    87      * This function is for the miscellaneous control messages.
       
    88      * This is not an active function, one-shot only.
       
    89      * @param aMmsHeaders reference to CMmsHeaders class.
       
    90      * @param aEncodeBuffer buffer to hold the encoded data,
       
    91      */
       
    92     IMPORT_C void EncodeHeadersL(
       
    93         CMmsHeaders& aMmsHeaders,
       
    94         CBufFlat& aEncodeBuffer );
       
    95 
       
    96     /**
       
    97      * Start chunked encoding.
       
    98      * This method can be called only when it is known that the component
       
    99      * that handles the encoded data can use the callback to get more 
       
   100      * data chunks.
       
   101      *
       
   102      * @since v3.1
       
   103      * @param aEntryWrapper mixin for handling all message entry access
       
   104      * @param aMmsHeaders reference to CMmsHeaders class.
       
   105      * @param aEncodeBuffer buffer to hold the encoded data,
       
   106      * @param aStatus status of calling active object
       
   107      */
       
   108     IMPORT_C void StartChunkedL(
       
   109         MMmsEntryWrapper& aEntryWrapper,
       
   110         CMmsHeaders& aMmsHeaders,
       
   111         CBufFlat& aEncodeBuffer,
       
   112         TRequestStatus& aStatus );
       
   113 
       
   114 // from base class MMmsCodecDataSupplier
       
   115 
       
   116     /**
       
   117      * from MMmsCodecDataSupplier.
       
   118      * Give poiner to next encoded data chunk.
       
   119      *
       
   120      * @since v3.1
       
   121      * @param aDataPart pointer to the next encoded data part
       
   122      * @param aLastDataChunk 
       
   123      *     ETrue if this is the last data chunk
       
   124      *     EFalse if this is not the last data chunk
       
   125      * @return error code, KErrNone if all is well.
       
   126      *     If returns some other error, transaction must be cancelled.
       
   127      */
       
   128     virtual TInt GetNextDataPart(
       
   129         TPtrC8& aDataPart, TBool& aLastDataChunk );
       
   130     
       
   131     /**
       
   132      * from MMmsCodecDataSupplier.
       
   133      * Empty buffer and prepare next data part (synchronous encoding).
       
   134      * When needed, caller will tell HTTP stack that the next data part is
       
   135      * ready by calling RHTTPTransaction::NotifyNewRequestBodyPartL()
       
   136      *
       
   137      * @since v3.1
       
   138      * @return error code, KErrNone if all is well.
       
   139      *     If returns some other error, transaction must be cancelled.
       
   140      */
       
   141     virtual TInt ReleaseData();
       
   142     
       
   143     /**
       
   144      * from MMmsCodecDataSupplier.
       
   145      * Return the overall data size.
       
   146      *
       
   147      * @since v3.1
       
   148      * @return The overall data size if it is known, otherwise KErrNotFound
       
   149      */
       
   150     virtual TInt OverallDataSize();
       
   151     
       
   152     /**
       
   153      * from MMmsCodecDataSupplier.
       
   154      * Reset the data supplier.
       
   155      * Data supplier must start the data generation from the beginning again.
       
   156      *
       
   157      * @since v3.1
       
   158      * @return KErrNone if reset is successful, other error code if data
       
   159      *     supplier cannot be reset
       
   160      */
       
   161     TInt ResetSupplier();
       
   162 
       
   163 protected:
       
   164     
       
   165 private:
       
   166 
       
   167     CMmsEncode();
       
   168 
       
   169     /**
       
   170      * @param aFs file system handle.
       
   171      */
       
   172     void ConstructL( RFs& aFs );
       
   173 
       
   174     /**
       
   175      * from CMsgActive.
       
   176      *
       
   177      * Active object completion.
       
   178      */
       
   179     void DoRunL();
       
   180 
       
   181     /**
       
   182      * from CMsgActive.
       
   183      *    
       
   184      * Sweep the floor after everything has crashed.
       
   185      * @param aStatus completion code
       
   186      */
       
   187     void DoComplete( TInt& aStatus );
       
   188 
       
   189     /**
       
   190      * Select next state for state machine.
       
   191      */
       
   192     void SelectNextState();
       
   193 
       
   194     /**
       
   195      * Switch states.
       
   196      */
       
   197     void ChangeStateL();
       
   198 
       
   199     /**
       
   200      * Initialize members to allow one-shot functions.
       
   201      * (for short tasks no active object invocation is needed)
       
   202      */
       
   203     void Reset();
       
   204 
       
   205     /**
       
   206      * Encode headers.
       
   207      */
       
   208     void EncodeHeadersL();
       
   209     
       
   210     /**
       
   211      * Encode headers in chunked mode.
       
   212      */
       
   213     void EncodeHeadersChunkedL();
       
   214 
       
   215     /** 
       
   216      * Do one attachment at a time.
       
   217      */
       
   218     void EncodeAttachmentL();
       
   219     
       
   220     /**
       
   221      * Do the actual work, can be called from active loop or passive loop
       
   222      */
       
   223     void DoEncodeAttachmentL(); 
       
   224     
       
   225     /**
       
   226      * Get encoding length for one attachment
       
   227      * @return size of the encoded attachment headers and attachment data
       
   228      */
       
   229     TInt DoGetAttachmentEncodingLengthL();
       
   230     
       
   231     /**
       
   232      * Encode attachment headers into the buffer and open the attachment file
       
   233      * @param aAttachMan reference to attachment manager for accessing
       
   234      *        attachment information and opening the file
       
   235      * @return size of the attachment
       
   236      */
       
   237     TInt EncodeHeadersAndGetFileL( MMsvAttachmentManager& aAttachMan );
       
   238     
       
   239     /**
       
   240      * Get the encoded size of the mime headers and the attachment data
       
   241      * @param aAttachMan reference to attachment manager for accessing
       
   242      *        attachment information and opening the file
       
   243      * @return size of the encoded attachment headers and attachment data
       
   244      */
       
   245     TInt GetHeadersAndFileSizeL( MMsvAttachmentManager& aAttachMan );
       
   246     
       
   247     /**
       
   248      * Calculate the length of headers for the attachment
       
   249      * @param aAttachmentInfo attachmentInformation structure for current attacment
       
   250      * @param aHeaderLength total length of encoded headers
       
   251      * @param aFoundName ETrue the name is among content-type parameters
       
   252      *                   EFalse the name is in the recommended filename parameter
       
   253      * @param aContentTypeSize length of the content type header
       
   254      * @param aContentType assigned number for content type, -1 if not found
       
   255      * @param aContentTypeString content type in string format if aContentType == -1
       
   256      * @return pointer to attachment name in 8bit format if aFoundName == EFalse
       
   257      *     If aFoundName == ETrue, returns NULL, because name in included in content
       
   258      *     type parameters and is not added separately.
       
   259      *     Caller must delete buffer when no longer needed.
       
   260      */
       
   261     HBufC8* CalculateAttachmentHeaderLengthL(
       
   262         CMsvAttachment& aAttachmentInfo,
       
   263         TUint& aHeaderLength,
       
   264         TBool& aFoundName,
       
   265         TUint& aContentTypeSize,
       
   266         TInt8& aContentType,
       
   267         TPtrC8& aContentTypeString );
       
   268     
       
   269     /**
       
   270      * Encode headers for one attachment
       
   271      * @param aSize size of the attachment binary data
       
   272      * @param aHeaderSize size of the headers in encoded format
       
   273      * @param aFoundName ETrue if the name parameter is among the 
       
   274      *        Content type parameters in MIME headers
       
   275      * @param aContentTypeSize size of the content type header
       
   276      * @param aContentType assigned number for the content type
       
   277      * @param aContentTypeString content type in string format if
       
   278      *        no assigned number is available
       
   279      * @param aNameString name of the attachment if aFoundName == EFalse
       
   280      */
       
   281     void EncodeAttachmentHeadersL(
       
   282         TUint aSize,
       
   283         TUint aHeaderSize,
       
   284         TBool aFoundName,
       
   285         TUint aContentTypeSize,
       
   286         TInt8 aContentType,
       
   287         TPtrC8& aContentTypeString,
       
   288         TPtrC8& aNameString );
       
   289 
       
   290     /**
       
   291      * Write all attachment data to the buffer
       
   292      * @param aAttachFile open handle for attachment file
       
   293      *     After reading the file pointer will point past data read
       
   294      * @param aSize amount of data to be read
       
   295      */
       
   296     void EncodeAttachmentData( RFile& aAttachFile, TInt aSize );
       
   297 
       
   298     /**
       
   299      * Cleanup (close streams etc.).
       
   300      */
       
   301     void FinishL();
       
   302     
       
   303     /**
       
   304      * Encode MMS request headers depending on the PDU type
       
   305      */
       
   306     void EncodeRequestHeadersL();
       
   307 
       
   308     // As different transactions have widely different headers,
       
   309     // a separate routine is used for each to avoid lots of extra
       
   310     // work when certain headers are not needed anyway.
       
   311 
       
   312     // If new transactions (message types) are added, they need
       
   313     // special handling anyway.
       
   314 
       
   315     /**
       
   316      * Send Request.
       
   317      */
       
   318     void EncodeSendRequestHeadersL();
       
   319 
       
   320     /**
       
   321      * Notify response.
       
   322      */
       
   323     void EncodeNotifyResponse();
       
   324 
       
   325     /**
       
   326      * Delivery acknowledgement.
       
   327      */
       
   328     void EncodeAcknowledgeIndication();
       
   329 
       
   330     /**
       
   331      * Mms notification.
       
   332      */
       
   333     void EncodeMmsNotificationL();
       
   334 
       
   335     // PDUs reserved for testing purposes
       
   336     
       
   337     /**
       
   338      * Send confirmation
       
   339      */
       
   340     void EncodeSendConfirmationL();
       
   341 
       
   342     /**
       
   343      * Retrieve confirmation.
       
   344      */
       
   345     void EncodeRetrieveConfirmationL();
       
   346 
       
   347     /**
       
   348      * Delivery report.
       
   349      */
       
   350     void EncodeDeliveryReportL();
       
   351 
       
   352     // MMS encapsulation version 1.1 PDUs
       
   353 
       
   354     /**
       
   355      * Forward Request.
       
   356      */
       
   357     void EncodeForwardRequestL();
       
   358 
       
   359     /**
       
   360      * Forward confirmation.
       
   361      * for testing purposes
       
   362      */
       
   363     void EncodeForwardConfirmationL();
       
   364 
       
   365     /**
       
   366      * ReadReply.
       
   367      * @param aPDUType KMmsMessageTypeReadRecInd or
       
   368      *    KMmsMessageTypeReadOrigInd (supported for testing purposes)
       
   369      */
       
   370     void EncodeReadReplyL();
       
   371 
       
   372     // MMS encapsulation 1.2 PDUs
       
   373 
       
   374     /**
       
   375      * MMBox store request.
       
   376      * @since 2.6
       
   377      */
       
   378     void EncodeMMBoxStoreRequestL();
       
   379 
       
   380     /**
       
   381      * MMBox store confirmation.
       
   382      * for testing purposes.
       
   383      * @since 2.6
       
   384      */
       
   385     void EncodeMMBoxStoreConfirmationL();
       
   386 
       
   387     /**
       
   388      * MMBox view request.
       
   389      * @since 2.6
       
   390      */
       
   391     void EncodeMMBoxViewRequestL();
       
   392 
       
   393     /**
       
   394      * MMBox view confirmation.
       
   395      * for testing purposes.
       
   396      * @since 2.6
       
   397      */
       
   398     void EncodeMMBoxViewConfirmationL();
       
   399 
       
   400     /**
       
   401      * MMBox upload request
       
   402      * @since 2.6
       
   403      */
       
   404     void EncodeMMBoxUploadRequestL();
       
   405 
       
   406     /**
       
   407      * MMBox upload confirmation
       
   408      * for testing purposes.
       
   409      * @since 2.6
       
   410      */
       
   411     void EncodeMMBoxUploadConfirmationL();
       
   412 
       
   413     /**
       
   414      * MMBox delete request or MMSC delete request
       
   415      * @since 2.6
       
   416      */
       
   417     void EncodeDeleteRequestL();
       
   418 
       
   419     /**
       
   420      * MMBox delete confirmation or MMSC delete confirmation.
       
   421      * for testing purposes.
       
   422      * @since 2.6
       
   423      */
       
   424     void EncodeDeleteConfirmationL();
       
   425 
       
   426     /**
       
   427      * MMBox description
       
   428      * for testing purposes.
       
   429      * @since 2.6
       
   430      */
       
   431     void EncodeMMBoxDescriptionL();
       
   432 
       
   433     // end of MMS encapsulation PDUs
       
   434 
       
   435     /**
       
   436      * Encode Text String (No Character set).
       
   437      * @param aString byte string
       
   438      */
       
   439     void EncodeTextString( const TDesC8& aString );
       
   440 
       
   441     /**
       
   442      * Encode Quoted Text String (No Character set).
       
   443      * This function adds a quote to the beginning of the text string.
       
   444      * needed for content-id
       
   445      * @param aString byte string
       
   446      */
       
   447     void EncodeQuotedTextString( const TDesC8& aString );
       
   448 
       
   449     /**
       
   450      * Encode Text String.
       
   451      * Checks if string can be sent as plain ASCII,
       
   452      *     if not, encodes it into utf-8
       
   453      * @param aString unicode string
       
   454      */
       
   455     void EncodeTextStringL( const TDesC& aString );
       
   456 
       
   457     /**
       
   458      * Encode date.
       
   459      * @param aDate local datetime in seconds from 1.1.1970
       
   460      */
       
   461     void EncodeDate( const TInt64& aDate );
       
   462     
       
   463     /**
       
   464      * Encode long integer.
       
   465      * @param 8 byte integer to be encoded
       
   466      */
       
   467     void EncodeLongInteger( const TInt64& aLongInteger );
       
   468 
       
   469     /**
       
   470      * Encode integer.
       
   471      * Will be encoded as short integer or long integer depending on value.
       
   472      * @param 4 byte integer to be encoded
       
   473      */
       
   474     void EncodeInteger( TUint aInteger );
       
   475 
       
   476     /**
       
   477      * Encode Sender.
       
   478      * The result is either a legal sender address or an "insert-address"
       
   479      *     token.
       
   480      * @param aSender pointer to sender name
       
   481      */
       
   482     void EncodeSenderL( const TPtrC& aSender );
       
   483 
       
   484     /**
       
   485      * Encode Address.
       
   486      * @param aAddress pointer to address
       
   487      */
       
   488     void EncodeAddressL( const TPtrC& aAddress );
       
   489 
       
   490     /**
       
   491      * Encode value length (long or short).
       
   492      * @param aLength value length that may be short or long
       
   493      */
       
   494     void EncodeValueLength( TUint aLength );
       
   495 
       
   496     /**
       
   497      * Encode Uintvar.
       
   498      * @param aInteger the integer to be coded - usually a length
       
   499      */
       
   500     void EncodeUintvar( TUint aInteger );
       
   501 
       
   502     /**
       
   503      * Check how many bytes are needed to encode a Uintvar.
       
   504      * @param aInteger the integer to be coded - usually a length
       
   505      * @return number of bytes needed in the encoding.
       
   506      */
       
   507     TInt GetUintvarLength( TUint aInteger );
       
   508 
       
   509     /**
       
   510      * Encode recipient.
       
   511      * @param aRecipientList array of recipient descriptors
       
   512      * @param aType recipient type (To, Cc, Bcc)
       
   513      */
       
   514     void EncodeRecipientL( const CDesCArray& aRecipientList,
       
   515         TMmsRecipients aType );
       
   516 
       
   517     /**
       
   518      * Encode optional encoded string text.
       
   519      * @param aHeader assigned header byte
       
   520      * @param aString text
       
   521      */
       
   522     void EncodeOptionalStringL( TUint8 aHeader, const TPtrC16& aString );
       
   523 
       
   524     /**
       
   525      * Encode optional encoded string text.
       
   526      * @param aHeader assigned header byte
       
   527      * @param aString text
       
   528      */
       
   529     void EncodeOptionalString( TUint8 aHeader, const TPtrC8& aString );
       
   530 
       
   531     /**
       
   532      * Encode absolute time or a time interval.
       
   533      * @param aInterval interval.
       
   534      * @param aDate absolute date. If date is 0, interval is encoded.
       
   535      */
       
   536     void EncodeIntervalOrDate( TInt aInterval, const TInt64& aDate );
       
   537 
       
   538     /**
       
   539      * Encode ReplyCharging size if defined.
       
   540      * @param aReplyChargingSize maximum number in octets for the reply-MM
       
   541      */
       
   542     void EncodeReplyChargingSize( TInt aReplyChargingSize );
       
   543 
       
   544     /**
       
   545      * Encode specified header if value is different from zero.
       
   546      * Encoding must be assigned byte value.
       
   547      * @param aHeader assigned header byte
       
   548      * @param aValue assigned value for the header
       
   549      */
       
   550     void EncodeOptionalByte( TUint8 aHeader, TInt aValue );
       
   551 
       
   552     /**
       
   553      * Encode specified header (mandatory).
       
   554      * Encoding must be assigned byte value
       
   555      * @param aHeader assigned header byte
       
   556      * @param aValue assigned value for the header
       
   557      */
       
   558     void EncodeMandatoryByte( TUint8 aHeader, TInt aValue );
       
   559 
       
   560     /**
       
   561      * Encode optional header that may be date or interval
       
   562      * @param aHeader assigned header byte
       
   563      * @param aInterval interval.
       
   564      * @param aDate absolute date. If date is 0, interval is encoded.
       
   565      * if both date and interval are 0, header is not added
       
   566      */
       
   567     void EncodeOptionalIntervalOrDate( TUint8 aHeader,
       
   568         TInt aInterval,
       
   569         const TInt64& aDate );
       
   570 
       
   571     /**
       
   572      * Encode header byte and 8-bit Text String (No Character set).
       
   573      * @param aHeader assigned header byte
       
   574      * @param aString byte string
       
   575      */
       
   576     void EncodeHeaderAndTextString( TUint8 aHeader,
       
   577         const TDesC8& aString );
       
   578 
       
   579     /**
       
   580      * Check if string contains only US-ASCII characters.
       
   581      * @param aString the string to be checked
       
   582      * @return ETrue = ASCII, EFalse = needs encoding
       
   583      */
       
   584     TBool IsStringSafe( const TDesC& aString );
       
   585     
       
   586     /**
       
   587      * Check if string contains only US-ASCII characters.
       
   588      * @param aString the string to be checked
       
   589      * @param aNumNonSafe number of characters >= 0x7F
       
   590      * @return ETrue = ASCII, EFalse = needs encoding
       
   591      */
       
   592     TBool IsStringSafe( const TDesC8& aString, TInt& aNumNonSafe );
       
   593 
       
   594     /**
       
   595      * Encode Content type header with start parameter.
       
   596      * The content-id of the attachment is searched. If the
       
   597      * attachment has no content-id, an id is generated by a random
       
   598      * number generator (not globally unique).
       
   599      * @param aRootId Internal Id of the attachment that is the root
       
   600      *     part of the message.
       
   601      */
       
   602     void EncodeMultipartRelatedHeaderL( const TMsvAttachmentId aRootId );
       
   603 
       
   604     /**
       
   605      * Encode Content type as multipart/mixed (no start specified).
       
   606      */
       
   607     void EncodeMultipartMixedHeaderL();
       
   608 
       
   609     /**
       
   610      * Encode keyword array.
       
   611      */
       
   612     void EncodeKeywordArrayL();
       
   613 
       
   614     /**
       
   615      * Encode optional integer. If value is 0, it is not added
       
   616      * @param aHeader assigned header byte
       
   617      * @aValue value to be encoded as an integer
       
   618      */
       
   619     void EncodeOptionalInteger( TUint8 aHeader, TUint aValue );
       
   620 
       
   621     /**
       
   622      * Encode attribute headers from array.
       
   623      * This is the list of information elements required for each message
       
   624      * @param aAttributeArray list of attributes as assigned numbers
       
   625      */
       
   626     void EncodeAttributes( RArray<TUint>& aAttributeArray );
       
   627 
       
   628     /**
       
   629      * Encode X-Mms-MM-State headers from an array.
       
   630      * In MMBox view PDUs this header may appear multiple times
       
   631      * @param aStateArray list of states used for filtering messages
       
   632      * (items have values draft/sent/new/retrieved/forwarded)
       
   633      */
       
   634     void EncodeMMBoxStates( RArray<TInt>& aStateArray );
       
   635 
       
   636     /**
       
   637      * Encode content location array.
       
   638      * Encodes content location headers in cases where more than one are
       
   639      *     allowed
       
   640      */
       
   641     void EncodeContentLocationArray();
       
   642 
       
   643     /**
       
   644      * Encode the three headers appearing at the beginning of most PDUs.
       
   645      * TID is not always required. If length of TID is 0, the header is
       
   646      *     not added.
       
   647      * @param aMessageType value for X-Mms-Message-Type header
       
   648      * @param aTID transaction ID
       
   649      * @param aVersion MMS encapsulation version number
       
   650      */
       
   651     void EncodeStartingHeaders( TInt aMessageType,
       
   652         const TPtrC8& aTID, TInt aVersion );
       
   653         
       
   654     /**
       
   655      * Encode Application Id and Reply to Application id as content type parameters
       
   656      */    
       
   657     void EncodeApplicationIdParametersL();    
       
   658 
       
   659     /**
       
   660      * Dump binary data into file.
       
   661      */
       
   662     void Dump();
       
   663     
       
   664     /**
       
   665      * Append a chunk of binary data into file - for chunked encoding support
       
   666      */
       
   667     void DumpAppend();
       
   668     
       
   669     /**
       
   670      * Encode that application id, reply application id and application info
       
   671      */
       
   672     void EncodeApplicationHeadersL();
       
   673     
       
   674     /**
       
   675      *  Encode cancel request PDU - for testing only
       
   676      */    
       
   677     void EncodeCancelRequest();
       
   678     
       
   679     /**
       
   680      * Encode cancel response PDU
       
   681      */
       
   682     void EncodeCancelResponse();
       
   683     
       
   684     /**
       
   685      * Encode utf8 string into MIME quoted printable format.
       
   686      * @param aSource string in utf8 character set.
       
   687      * @return data in encoded format. Caller must delete buffer
       
   688      */
       
   689     HBufC8* EncodeQuotedPrintableWordL( const TPtrC8& aSource );
       
   690     
       
   691     /**
       
   692      * Encode utf8 string into MIME base64 format.
       
   693      * @param aSource string in utf8 character set
       
   694      * @return data in encoded format. Caller must delete buffer
       
   695      */
       
   696     HBufC8* EncodeBase64WordL( const TPtrC8& aSource );
       
   697 
       
   698     /**
       
   699      * Open the message store(Edit mode) and process attachments 
       
   700      * for further encoding
       
   701      * @param None
       
   702      * @return void
       
   703      */
       
   704     void PreProcessAttachmentDataL();
       
   705 
       
   706     /**
       
   707      * Check and proceed if given attachment can be encoded using 
       
   708      * target encoding type based on its content type.
       
   709      * @param aAttachmentInfo attachment of the msv entry
       
   710      *        aMimeHeaders corresponding attachment mime headers
       
   711      * @return true/false based on attachment content type
       
   712      */
       
   713     TBool CheckAndUpdateAttachmentL( CMsvAttachment& aAttachmentInfo,
       
   714                                      CMsvMimeHeaders& aMimeHeaders );
       
   715     
       
   716 
       
   717     /**
       
   718      * checks if input content type is supported for target encoding 
       
   719      * @param aSrcCharSetMIBEnum MIB enum reprsenting current data format 
       
   720      *        aTargetCharSetMIBEnum target encoding MIB enum
       
   721      *        aAttachmentInfo attachment data to be converted 
       
   722      * @return true/false based on encoding success/failure
       
   723      */
       
   724     TBool ProcessAndConvertAttachmentDataL( TUint aSrcCharSetMIBEnum,
       
   725                                             TUint aTargetCharSetMIBEnum, 
       
   726                                             CMsvAttachment& aAttachmentInfo);
       
   727 
       
   728     /**
       
   729      * checks if input content type is supported for target encoding 
       
   730      * @param aContentType to check if the attachment data encoding is supported
       
   731      * @return true/false based on attachment content type
       
   732      */
       
   733     TBool IsConversionSupportedContentType( TInt aContentType );
       
   734 
       
   735 
       
   736     
       
   737 private:    // Data
       
   738     RFs                 iFs; // file system
       
   739     TInt                iError;
       
   740     TInt                iState;
       
   741     MMmsEntryWrapper*   iEntryWrapper;
       
   742     CBufFlat*           iEncodeBuffer;
       
   743     CMmsHeaders*        iMmsHeaders;
       
   744     CMsvMimeHeaders*    iMimeHeaders;
       
   745     TInt                iPosition; // pointer to encode buffer (if needed)
       
   746     TInt                iNumberOfAttachments;
       
   747     TInt                iCurrentAttachment; // AttachmentManager index
       
   748     TFileName           iFileName;
       
   749 #ifndef _NO_MMSS_LOGGING_
       
   750 // only needed if output logging is enabled
       
   751 // parse buffer as member to save stack space
       
   752     TParse              iParse;     
       
   753 #endif
       
   754     TMsvId              iCurrentMessageId;
       
   755     
       
   756     TInt                iOverallDataSize;
       
   757     TBool               iLastChunk;
       
   758     TBool               iOnlyOneChunk;
       
   759     TInt                iEncodingStage; // stage for chunked encoding
       
   760     // Handle for the current attachment.
       
   761     // If the file is large it may be read to the buffer in chunks.
       
   762     // The file is kept open between reads. We want sole access.
       
   763     RFile               iAttachFile;
       
   764     // The attachment file is kept open if it is read in several parts.
       
   765     // In destructor the file must be closed in case the transaction
       
   766     // terminates with error
       
   767     TBool               iFileOpen;
       
   768     // Size of the current attachment.
       
   769     // This will allow us to keep track of the amount of data read from the file
       
   770     TInt                iCurrentFileSize;
       
   771     // The stage variable that will keep track of the part of message that
       
   772     // is going to be encoded next in case of chunked encoding
       
   773     TInt                iDataSupplierStage;
       
   774     // The max size of the ecode buffer for chunked encoding.
       
   775     TInt                iBufferSize; 
       
   776     // object to provide chaconv functionalities
       
   777     CMsgTextUtils*      iTextUtils;
       
   778     // target encoding type
       
   779     TUint               iTargetEncodingType;
       
   780     };
       
   781 
       
   782 #endif      // CMMSENCODE_H
       
   783             
       
   784 // End of File