epoc32/include/app/imcvcodc.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 1999-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 "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 /**
    16  * @file 
    17  * @publishedAll
    18  * @released
    19  */
    20 
    21 #if !defined(__IMCVCODC_H__)
    22 #define __IMCVCODC_H__
    23 
    24 #include <s32buf.h>
    25 #include <s32stor.h>
    26 #include <txtrich.h>
    27 #include <miutatch.h>
    28 #include <miutconv.h>
    29 #include <miuthdr.h>
    30 #include <mentact.h>		// CMsgActive
    31 
    32 #include <imcvdata.h>
    33 #include <imcvtext.h>
    34 #include <imutdll.h>
    35 
    36 #define KBase64 _L("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
    37 #define KCharFormat _L("%c")
    38 
    39 // Shared implementation code	
    40 //----------------------------------------------------------------------------------------
    41 class TImCodec
    42 //----------------------------------------------------------------------------------------
    43 /**
    44 @publishedAll
    45 @released
    46 */
    47 	{
    48 protected:
    49 	// base64 and UU coding defines.
    50 	enum EMaskValues{ ESixBitMask = 0x3F, EEightBitMask = 0xFF };
    51 	enum EMaskShiftValues{ ESix = 6, EFour = 4, ETwo = 2, EZero = 0 };
    52 
    53 public:
    54 	virtual TInt Encode( const TDesC8& aSrcString, TDes8& rDestString)=0 ;
    55 	virtual TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine)=0;
    56 
    57 protected:
    58 	// TImCodec();
    59 	inline TBool IsDigit( TChar aChar );
    60 	};
    61 
    62 
    63 // Interface for sending file data.
    64 //----------------------------------------------------------------------------------------
    65 class TImFileCodec : public TImCodec
    66 //----------------------------------------------------------------------------------------
    67 /**
    68 @publishedAll
    69 @released
    70 */
    71 	{
    72 public:
    73 	virtual TInt PrefixNextLineL( TDes8& rOutputLine, const TFileName& aName, TInt& rPaddingCount );
    74 	virtual TInt PostfixNextLine( TDes8& rOutputLine, TInt& rPaddingCount );
    75 	virtual void Initialise();
    76 
    77 protected:
    78 	TInt iPrefixState;
    79 	TInt iPostfixState;
    80 	};	
    81 
    82 // Dummy, just copies
    83 //----------------------------------------------------------------------------------------
    84 class TImCodecNull :  public TImFileCodec
    85 //----------------------------------------------------------------------------------------
    86 /**
    87 @publishedAll
    88 @released
    89 */
    90 	{
    91 public:
    92 	TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
    93 	TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine);
    94 	};
    95 	
    96 // Quoted-printable encoding/decoding
    97 
    98 //----------------------------------------------------------------------------------------
    99 class TImCodecQP : public TImFileCodec
   100 //----------------------------------------------------------------------------------------
   101 /**
   102 @publishedAll
   103 @released
   104 */
   105 	{
   106 public:
   107 	IMPORT_C TImCodecQP();
   108 	IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
   109 	IMPORT_C TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine);
   110 
   111 	// Not to be used anymore..
   112 	IMPORT_C TInt EncodeRichText( const TDesC8& aInputLine, TDes8& rOutputLine);
   113 	IMPORT_C TInt DecodeRichText( const TDesC8& aSrcString, TDes& rDestString );
   114 
   115 	// Functions which allow flexiblity. Can replace the '=' char or add characters..
   116 	// to what is defined as 'plain.
   117 	inline void AddPlainChar(const TDesC8&  aCharList );
   118 	inline void AddEncodeChar(const TDesC8&  aCharList );
   119 	inline void SetQPChar( TUint8 aChar);
   120 
   121 	inline TUint8 ReplacementChar( TChar aControlChar );
   122 	inline TBool IsPlain( TChar aChar );
   123 
   124 private:
   125 	TBool SmartBreak( TInt written, const TDesC8& pSource );
   126 	inline TBool IsBreakable( TChar aChar);
   127 	inline void AddSoftLineBreak(TDes8& aPtr, TInt& aPadding, TInt& aWritten);
   128 	inline void AddSoftLineBreak(const TUint8* apEnd, TUint8* aPtr, TInt& aPadding, TInt& aWritten);
   129 
   130 private:
   131 	TUint8 iQPCharacter;
   132 	TPtrC8 iPlainCharList;  
   133 	TPtrC8 iEncodeCharList;  
   134 
   135 	TInt iPaddingCount;
   136 	};
   137 
   138 
   139 
   140 // Base64 coding/decoding
   141 
   142 //----------------------------------------------------------------------------------------
   143 class TImCodecB64 : public TImFileCodec
   144 //----------------------------------------------------------------------------------------
   145 /**
   146 @publishedAll
   147 @released
   148 */
   149 	{
   150 private:
   151 	// base64 coding defines
   152 	enum{ EPadChar = 64 };
   153 
   154 public:
   155 	IMPORT_C TImCodecB64();
   156 	IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
   157 	IMPORT_C TBool Decode( const TDesC8& aSrcString, TDes8& rDestString);
   158  	IMPORT_C void  Initialise();
   159 
   160 protected:
   161 	TInt DoEncode(const TDesC8& aSrcString, TDes8& rDestString, TBool aInsertLineBreaks);
   162 
   163 private:
   164 	TInt iShiftStored;
   165 	TInt iMaskShiftStored;
   166 	};
   167 
   168 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS  
   169 #include "cimconvertheader.h"
   170 #endif
   171 
   172 // UU coding/decoding
   173 
   174 //----------------------------------------------------------------------------------------
   175 class TImCodecUU : public TImFileCodec
   176 //----------------------------------------------------------------------------------------
   177 /**
   178 @publishedAll
   179 @released
   180 */
   181 	{
   182 private:
   183 	// UU coding defines
   184 
   185 	enum{ ESpace = 32, EBackQuote = 96 };
   186 
   187 	enum TImBodyPostfix
   188 		{
   189 		EInvertedComma = 0,
   190 		EEndString,
   191 		EEndOfPostfix
   192 		};
   193 
   194 public:
   195 	IMPORT_C TImCodecUU();
   196 	IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString );
   197 	IMPORT_C TBool Decode( const TDesC8& aSrcString, TDes8& rDestString );
   198 	TInt PrefixNextLineL( TDes8& rOutputLine, const TFileName& aName, TInt& rPaddingCount );
   199 	TInt PostfixNextLine( TDes8& rOutputLine, TInt& rPaddingCount );
   200 private:
   201 	void AppendFilenameL( TDes8& rOutputLine, const TFileName& aName );
   202 	
   203 	};
   204 
   205 #endif
   206