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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #if !defined(__IMCVCODC_H__)
22 #define __IMCVCODC_H__
30 #include <mentact.h> // CMsgActive
36 #define KBase64 _L("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
37 #define KCharFormat _L("%c")
39 // Shared implementation code
40 //----------------------------------------------------------------------------------------
42 //----------------------------------------------------------------------------------------
49 // base64 and UU coding defines.
50 enum EMaskValues{ ESixBitMask = 0x3F, EEightBitMask = 0xFF };
51 enum EMaskShiftValues{ ESix = 6, EFour = 4, ETwo = 2, EZero = 0 };
54 virtual TInt Encode( const TDesC8& aSrcString, TDes8& rDestString)=0 ;
55 virtual TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine)=0;
59 inline TBool IsDigit( TChar aChar );
63 // Interface for sending file data.
64 //----------------------------------------------------------------------------------------
65 class TImFileCodec : public TImCodec
66 //----------------------------------------------------------------------------------------
73 virtual TInt PrefixNextLineL( TDes8& rOutputLine, const TFileName& aName, TInt& rPaddingCount );
74 virtual TInt PostfixNextLine( TDes8& rOutputLine, TInt& rPaddingCount );
75 virtual void Initialise();
83 //----------------------------------------------------------------------------------------
84 class TImCodecNull : public TImFileCodec
85 //----------------------------------------------------------------------------------------
92 TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
93 TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine);
96 // Quoted-printable encoding/decoding
98 //----------------------------------------------------------------------------------------
99 class TImCodecQP : public TImFileCodec
100 //----------------------------------------------------------------------------------------
107 IMPORT_C TImCodecQP();
108 IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
109 IMPORT_C TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine);
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 );
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);
121 inline TUint8 ReplacementChar( TChar aControlChar );
122 inline TBool IsPlain( TChar aChar );
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);
132 TPtrC8 iPlainCharList;
133 TPtrC8 iEncodeCharList;
140 // Base64 coding/decoding
142 //----------------------------------------------------------------------------------------
143 class TImCodecB64 : public TImFileCodec
144 //----------------------------------------------------------------------------------------
151 // base64 coding defines
152 enum{ EPadChar = 64 };
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();
161 TInt DoEncode(const TDesC8& aSrcString, TDes8& rDestString, TBool aInsertLineBreaks);
165 TInt iMaskShiftStored;
168 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
169 #include "cimconvertheader.h"
172 // UU coding/decoding
174 //----------------------------------------------------------------------------------------
175 class TImCodecUU : public TImFileCodec
176 //----------------------------------------------------------------------------------------
185 enum{ ESpace = 32, EBackQuote = 96 };
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 );
201 void AppendFilenameL( TDes8& rOutputLine, const TFileName& aName );