epoc32/include/imcvcodc.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- a/epoc32/include/imcvcodc.h	Tue Mar 16 16:12:26 2010 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,360 +0,0 @@
     1.4 -// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 -// All rights reserved.
     1.6 -// This component and the accompanying materials are made available
     1.7 -// 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
     1.8 -// which accompanies this distribution, and is available
     1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 -//
    1.11 -// Initial Contributors:
    1.12 -// Nokia Corporation - initial contribution.
    1.13 -//
    1.14 -// Contributors:
    1.15 -//
    1.16 -// Description:
    1.17 -//
    1.18 -
    1.19 -
    1.20 -#if !defined(__IMCVCODC_H__)
    1.21 -#define __IMCVCODC_H__
    1.22 -
    1.23 -#include <s32buf.h>
    1.24 -#include <s32stor.h>
    1.25 -#include <txtrich.h>
    1.26 -#include <miutatch.h>
    1.27 -#include <miutconv.h>
    1.28 -#include <miuthdr.h>
    1.29 -#include <mentact.h>		// CMsgActive
    1.30 -
    1.31 -#include <imcvdata.h>
    1.32 -#include <imcvtext.h>
    1.33 -#include <imutdll.h>
    1.34 -
    1.35 -#define KBase64 _L("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
    1.36 -#define KCharFormat _L("%c")
    1.37 -
    1.38 - // Maximum length allowed for an 'encoded-word' rfc2047
    1.39 -const TInt KEncodedWordMaxLength = 75;
    1.40 -
    1.41 -// All encoding information except data and charset name length. =?B?=?    => 7
    1.42 -const TInt KMaxEncodedInformationLength = 7;
    1.43 -
    1.44 -// Length of the field name, eg "Subject: ". This may change as other fields are processed.  
    1.45 -const TInt KMaxHeaderFieldNameLength = 12;
    1.46 -
    1.47 -const TInt KImCvFinished=(-1);
    1.48 -const TInt KImCvAdvance=(1);
    1.49 -
    1.50 -
    1.51 -// error states involved in sending attachments etc.
    1.52 -/**
    1.53 -@internalComponent
    1.54 -@deprecated
    1.55 -*/
    1.56 -enum TIattErrorCode
    1.57 -	{
    1.58 -	KImAttNoError = 0,
    1.59 -	KImAttFinished = 1
    1.60 -	};
    1.61 -
    1.62 -
    1.63 -/**
    1.64 -@internalComponent
    1.65 -@released
    1.66 -*/
    1.67 -enum TImBodyConvAlgorithm
    1.68 -	{
    1.69 -	ENoAlgorithm,
    1.70 -	EQPEncode,
    1.71 -	EQPDecode,
    1.72 -	EBase64Encode,
    1.73 -	EBase64Decode,
    1.74 -	EUUEncode,
    1.75 -	EUUDecode
    1.76 -	};
    1.77 -	
    1.78 -// Used in CImSendConvert
    1.79 -/**
    1.80 -@internalComponent
    1.81 -@deprecated
    1.82 -*/
    1.83 -enum TImSendEncoding 
    1.84 -	{ 
    1.85 -	ESendNoAlgorithm,
    1.86 -	ESendMimeAlgorithm
    1.87 -	};	
    1.88 -
    1.89 -struct SAttachmentInfo
    1.90 -/**
    1.91 -@internalComponent
    1.92 -@released
    1.93 -*/
    1.94 -	{
    1.95 -	TInt iSize;
    1.96 -	TFileName iName;
    1.97 -	TFileName iPath;
    1.98 -	TBool iComplete;
    1.99 -	};
   1.100 -
   1.101 -// Shared implementation code	
   1.102 -//----------------------------------------------------------------------------------------
   1.103 -class TImCodec
   1.104 -//----------------------------------------------------------------------------------------
   1.105 -/**
   1.106 -@internalAll
   1.107 -@released
   1.108 -*/
   1.109 -	{
   1.110 -protected:
   1.111 -	// base64 and UU coding defines.
   1.112 -	enum EMaskValues{ ESixBitMask = 0x3F, EEightBitMask = 0xFF };
   1.113 -	enum EMaskShiftValues{ ESix = 6, EFour = 4, ETwo = 2, EZero = 0 };
   1.114 -
   1.115 -public:
   1.116 -	virtual TInt Encode( const TDesC8& aSrcString, TDes8& rDestString)=0 ;
   1.117 -	virtual TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine)=0;
   1.118 -
   1.119 -protected:
   1.120 -	// TImCodec();
   1.121 -	inline TBool IsDigit( TChar aChar );
   1.122 -	};
   1.123 -
   1.124 -
   1.125 -// Interface for sending file data.
   1.126 -//----------------------------------------------------------------------------------------
   1.127 -class TImFileCodec : public TImCodec
   1.128 -//----------------------------------------------------------------------------------------
   1.129 -/**
   1.130 -@internalAll
   1.131 -@released
   1.132 -*/
   1.133 -	{
   1.134 -public:
   1.135 -	virtual TInt PrefixNextLineL( TDes8& rOutputLine, const TFileName& aName, TInt& rPaddingCount );
   1.136 -	virtual TInt PostfixNextLine( TDes8& rOutputLine, TInt& rPaddingCount );
   1.137 -	virtual void Initialise();
   1.138 -
   1.139 -protected:
   1.140 -	TInt iPrefixState;
   1.141 -	TInt iPostfixState;
   1.142 -	};	
   1.143 -
   1.144 -// Dummy, just copies
   1.145 -//----------------------------------------------------------------------------------------
   1.146 -class TImCodecNull :  public TImFileCodec
   1.147 -//----------------------------------------------------------------------------------------
   1.148 -/**
   1.149 -@internalComponent
   1.150 -@released
   1.151 -*/
   1.152 -	{
   1.153 -public:
   1.154 -	TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
   1.155 -	TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine);
   1.156 -	};
   1.157 -	
   1.158 -// Quoted-printable encoding/decoding
   1.159 -
   1.160 -//----------------------------------------------------------------------------------------
   1.161 -class TImCodecQP : public TImFileCodec
   1.162 -//----------------------------------------------------------------------------------------
   1.163 -/**
   1.164 -@internalAll
   1.165 -@released
   1.166 -*/
   1.167 -	{
   1.168 -public:
   1.169 -	IMPORT_C TImCodecQP();
   1.170 -	IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
   1.171 -	IMPORT_C TBool Decode( const TDesC8& aInputLine, TDes8& rOutputLine);
   1.172 -
   1.173 -	// Not to be used anymore..
   1.174 -	IMPORT_C TInt EncodeRichText( const TDesC8& aInputLine, TDes8& rOutputLine);
   1.175 -	IMPORT_C TInt DecodeRichText( const TDesC8& aSrcString, TDes& rDestString );
   1.176 -
   1.177 -	// Functions which allow flexiblity. Can replace the '=' char or add characters..
   1.178 -	// to what is defined as 'plain.
   1.179 -	inline void AddPlainChar(const TDesC8&  aCharList );
   1.180 -	inline void AddEncodeChar(const TDesC8&  aCharList );
   1.181 -	inline void SetQPChar( TUint8 aChar);
   1.182 -
   1.183 -	inline TUint8 ReplacementChar( TChar aControlChar );
   1.184 -	inline TBool IsPlain( TChar aChar );
   1.185 -
   1.186 -private:
   1.187 -	TBool SmartBreak( TInt written, const TDesC8& pSource );
   1.188 -	inline TBool IsBreakable( TChar aChar);
   1.189 -	inline void AddSoftLineBreak(TDes8& aPtr, TInt& aPadding, TInt& aWritten);
   1.190 -	inline void AddSoftLineBreak(const TUint8* apEnd, TUint8* aPtr, TInt& aPadding, TInt& aWritten);
   1.191 -
   1.192 -private:
   1.193 -	TUint8 iQPCharacter;
   1.194 -	TPtrC8 iPlainCharList;  
   1.195 -	TPtrC8 iEncodeCharList;  
   1.196 -
   1.197 -	TInt iPaddingCount;
   1.198 -	};
   1.199 -
   1.200 -
   1.201 -
   1.202 -// Base64 coding/decoding
   1.203 -
   1.204 -//----------------------------------------------------------------------------------------
   1.205 -class TImCodecB64 : public TImFileCodec
   1.206 -//----------------------------------------------------------------------------------------
   1.207 -/**
   1.208 -@publishedAll
   1.209 -@released
   1.210 -*/
   1.211 -	{
   1.212 -private:
   1.213 -	// base64 coding defines
   1.214 -	enum{ EPadChar = 64 };
   1.215 -
   1.216 -public:
   1.217 -	IMPORT_C TImCodecB64();
   1.218 -	IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
   1.219 -	IMPORT_C TBool Decode( const TDesC8& aSrcString, TDes8& rDestString);
   1.220 - 	IMPORT_C void  Initialise();
   1.221 -
   1.222 -protected:
   1.223 -	TInt DoEncode(const TDesC8& aSrcString, TDes8& rDestString, TBool aInsertLineBreaks);
   1.224 -
   1.225 -private:
   1.226 -	TInt iShiftStored;
   1.227 -	TInt iMaskShiftStored;
   1.228 -	};
   1.229 -
   1.230 -class TImCodecB64WithLineBreaks : public TImCodecB64
   1.231 -/**
   1.232 -@internalComponent
   1.233 -@released
   1.234 -*/
   1.235 -	{
   1.236 -public:
   1.237 -	TInt Encode(const TDesC8& aSrcString, TDes8& rDestString);
   1.238 -	};
   1.239 -
   1.240 -
   1.241 -// UU coding/decoding
   1.242 -
   1.243 -//----------------------------------------------------------------------------------------
   1.244 -class TImCodecUU : public TImFileCodec
   1.245 -//----------------------------------------------------------------------------------------
   1.246 -/**
   1.247 -@publishedAll
   1.248 -@released
   1.249 -*/
   1.250 -	{
   1.251 -private:
   1.252 -	// UU coding defines
   1.253 -
   1.254 -	enum{ ESpace = 32, EBackQuote = 96 };
   1.255 -
   1.256 -	enum TImBodyPostfix
   1.257 -		{
   1.258 -		EInvertedComma = 0,
   1.259 -		EEndString,
   1.260 -		EEndOfPostfix
   1.261 -		};
   1.262 -
   1.263 -public:
   1.264 -	IMPORT_C TImCodecUU();
   1.265 -	IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString );
   1.266 -	IMPORT_C TBool Decode( const TDesC8& aSrcString, TDes8& rDestString );
   1.267 -	TInt PrefixNextLineL( TDes8& rOutputLine, const TFileName& aName, TInt& rPaddingCount );
   1.268 -	TInt PostfixNextLine( TDes8& rOutputLine, TInt& rPaddingCount );
   1.269 -private:
   1.270 -	void AppendFilenameL( TDes8& rOutputLine, const TFileName& aName );
   1.271 -	
   1.272 -	};
   1.273 -
   1.274 -
   1.275 -
   1.276 -
   1.277 -// For converting a text string to/from encoded form
   1.278 -// Note: 'Word' here has special meaning derived from the one defined in rfc2047.
   1.279 -// It refers to one encoding instance.
   1.280 -
   1.281 -//----------------------------------------------------------------------------------------
   1.282 -class CImConvertHeader : public CBase
   1.283 -//----------------------------------------------------------------------------------------
   1.284 -/**
   1.285 -@internalTechnology
   1.286 -@released
   1.287 -*/
   1.288 -	{
   1.289 -public:
   1.290 -	IMPORT_C static CImConvertHeader* NewL(CImConvertCharconv& aConverter);
   1.291 -	~CImConvertHeader();
   1.292 -
   1.293 -	IMPORT_C void SetMessageType(TBool aIsMIME); 
   1.294 -	IMPORT_C void DecodeAllHeaderFieldsL(CImHeader& rHeader); 
   1.295 -
   1.296 -	// Functions for decoding & converting descriptors
   1.297 -
   1.298 -	IMPORT_C void DecodeNonMIMEHeaderFieldL(const TDesC8& aBufIn, TDes& aBufOut); 
   1.299 -	IMPORT_C void DecodeHeaderFieldL(const TDesC8& aBufIn, TDes& aBufOut); 
   1.300 -	IMPORT_C void DecodeHeaderFieldL(const TDesC16& aBufIn, TDes& aBufOut); 
   1.301 -	IMPORT_C void ConvertHeaderFieldL(const TDesC16& aBufIn, RBuf8& aBufOut, TBool aIsAddressField); 
   1.302 -	
   1.303 -	// Header needed for retrieving encoding information, used in Send code.
   1.304 -    IMPORT_C void EncodeHeaderFieldL(const TDesC& aBufIn, RBuf8& aBufOut, 
   1.305 -            CArrayFix<TImHeaderEncodingInfo>* aInfoArray, TInt aState, TInt aArrayVal = 0);
   1.306 -
   1.307 -	IMPORT_C void EncodeHeaderFieldL(const TDesC& aBufIn, RBuf8& aBufOut,  
   1.308 -		                             const TUint aCharset, const TImHeaderEncodingInfo::TEncodingType aType, TBool aIsAddressField);
   1.309 -	
   1.310 -	IMPORT_C TBool FindEncodedWord(TPtrC8& aData, TInt& aInit,TInt& rStart, TInt& rEnd);
   1.311 -
   1.312 -	void Append(TDes& aBuffer, const TDesC8& aAddition);
   1.313 -	inline CImConvertCharconv& CharConv();
   1.314 -
   1.315 -	IMPORT_C TUint OverrideCharset() const;
   1.316 -	IMPORT_C void SetOverrideCharset(TUint aCharset);
   1.317 -
   1.318 -private:
   1.319 -	void ConstructL();
   1.320 -	CImConvertHeader(CImConvertCharconv&);
   1.321 -	// Functions dealing only with single 'encoded-word's
   1.322 -	void GetCharsetAndEncodeDataL(const TDesC& aBufIn, RBuf8& aBufOut, TImHeaderEncodingInfo& aInfo);
   1.323 -	void EncodeWordL(const TDesC& aBufIn, RBuf8& aBufOut, TImHeaderEncodingInfo& aInfo,
   1.324 -						const TDesC8& aCharsetName, RBuf8& aEncodedWord);
   1.325 -
   1.326 -	TBool DecodeWordL(const TDesC8& aBufIn, TDes& aBufOut, TInt rRemainder); 
   1.327 -	void DecodeRecipientListL( CDesCArray& aArray);
   1.328 -	void DecodeFieldL(const TDesC& aField);
   1.329 -
   1.330 -	TBool DoCharsetConversionL(const TDesC& aDataToConvert, RBuf8& aEncodedWord);
   1.331 -
   1.332 -	void DoEncodingL(RBuf8& aEncodedWord, TImHeaderEncodingInfo& aInfo);
   1.333 -
   1.334 -	TInt AddEncodedWordInfoL(const TDesC8& aEncodedWord, RBuf8& aBufOut, 
   1.335 -							 TImHeaderEncodingInfo& aInfo, const TDesC8& aCharsetName);
   1.336 -
   1.337 -	TBool IsAscii( TUint aChar ) const;
   1.338 -	TBool ExtractTextToEncode(const TDesC& aBufIn, TInt& rStart, TInt& rEnd, TBool aIsAddressField);
   1.339 -	void Insert(TDes8& aBuffer, const TDesC16& aInsert);
   1.340 -
   1.341 -private:
   1.342 -	TImHeaderEncodingInfo iEncodingInfo;
   1.343 -	CImConvertCharconv& iCharConv;
   1.344 -
   1.345 -	// Get access to QP/ Base64 encoding/decoding functions
   1.346 -	TImCodecB64	 iB64Codec;
   1.347 -	TImCodecQP	 iQPCodec;
   1.348 -
   1.349 -	// Need in the narrow build, to check if possible to convert to/from
   1.350 -	// the machines character set.
   1.351 -	TUint iCharacterSetId; 
   1.352 -
   1.353 -	CImHeader* iHeader;	
   1.354 -
   1.355 -	// Converted static variables used in EncodeWordL()
   1.356 -	TBool	isMIMEMessageHeader;
   1.357 -	TUint   iOverrideCharset;
   1.358 -	};
   1.359 -
   1.360 -
   1.361 -#include <imcvcodc.inl>
   1.362 -
   1.363 -#endif