messagingfw/msgsrvnstore/server/inc/cmsvversion1version2converter.h
changeset 22 bde600d88860
parent 0 8e480a14352b
equal deleted inserted replaced
21:08008ce8a6df 22:bde600d88860
       
     1 // Copyright (c) 2008-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 #ifndef __CMSVVERSION1VERSION2CONVERTER_H__
       
    17 #define __CMSVVERSION1VERSION2CONVERTER_H__
       
    18 
       
    19 
       
    20 
       
    21 #include <s32mem.h>
       
    22 #include <badesca.h>
       
    23 #include "msvdbadapter.h"
       
    24 #include "msvmessagedbadapter.h"
       
    25 #include "cmessageconvertermanager.h"
       
    26 #include "cmsvconverterwaiter.h"
       
    27 #include "CMsvCachedStore.h"
       
    28 
       
    29 // fwd declaration
       
    30 class MMsvMessageStoreConverter;
       
    31 
       
    32 class TPairedTUidHBufC8;
       
    33 /** TCommonHeaderField
       
    34 Enum specifying the common header fields
       
    35 */
       
    36 enum TCommonHeaderField
       
    37 	{
       
    38 	EFrom,
       
    39 	ETo,
       
    40 	ECC,
       
    41 	EBCC,
       
    42 	ESubject
       
    43 #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
       
    44 	,EInvalid
       
    45 #endif	
       
    46 	};
       
    47 
       
    48 typedef TInt32	TLogId;
       
    49 
       
    50 /**
       
    51 Defines the status of an acknowledgement for a recipient.
       
    52 */	
       
    53 	enum TSmsAckStatus
       
    54 		{
       
    55 /**
       
    56 An acknowledgement for this recipient has not been requested.
       
    57 */
       
    58 		ENoAckRequested		= 0,
       
    59 /**
       
    60 The delivery status for this recipient has been requested, but the status report
       
    61 has not yet been received.
       
    62 */
       
    63 		EPendingAck,
       
    64 /**
       
    65 A successful acknowledgement for this recipient has been received.
       
    66 */
       
    67 		EAckSuccessful,
       
    68 /**
       
    69 A failed acknowledgement for this recipient has been received.
       
    70 */
       
    71 		EAckError
       
    72 		};
       
    73 
       
    74 
       
    75 /** TMsgOutboxBodyEncoding
       
    76 Defines how emails will be encoded when they are sent.
       
    77 
       
    78 @internalAll 
       
    79 @released
       
    80 */
       
    81 
       
    82 enum TMsgOutboxBodyEncoding
       
    83 	{
       
    84 	EMsgOutboxDefault,
       
    85 	EMsgOutboxNoAlgorithm,
       
    86 	EMsgOutboxMIME,
       
    87 	EMsgOutboxMHTMLAsMIME,
       
    88 	EMsgOutboxMHTMLAlternativeAsMIME
       
    89 	};
       
    90 
       
    91 
       
    92 
       
    93 /** Message sending status for a recipient. 
       
    94 */
       
    95 	enum TRecipientStatus 
       
    96 							{	
       
    97 	/** Message is not sent. */
       
    98 							ENotYetSent=0,
       
    99 	/** Message has been sent. */
       
   100 							ESentSuccessfully=1,
       
   101 	/** Message sending failed. */
       
   102 				 			EFailedToSend=2};
       
   103 
       
   104 
       
   105 
       
   106 /**
       
   107 TImHeaderEncodingInfo
       
   108 Identifies the header encoding info.
       
   109 
       
   110 @internalAll 
       
   111 @released
       
   112 */
       
   113 
       
   114 class TImHeaderEncodingInfo
       
   115 	{
       
   116 public:
       
   117 
       
   118 	enum TFieldList 
       
   119 		{ 
       
   120 		EFrom, 		/**< "From" field. */
       
   121 		EReplyTo, 	/**< "Reply To" field. */
       
   122 		ETo, 		/**< "To" field. */
       
   123 		ECc, 		/**< "Cc" field. */
       
   124 		EBcc, 		/**< "Bcc" field. */
       
   125 		ESubject	/**< Subject field. */
       
   126 		};
       
   127 	/** Encoding types. */
       
   128 	enum TEncodingType 
       
   129 		{ 
       
   130 		EBase64, 		/**< Base64. */
       
   131 		EQP, 			/**< QP. */
       
   132 		ENoEncoding, 	/**< No encoding */
       
   133 		EUU				/**< UU. */
       
   134 		};
       
   135 
       
   136 public:
       
   137 	TImHeaderEncodingInfo();
       
   138 	TImHeaderEncodingInfo(const TImHeaderEncodingInfo& aFrom);
       
   139 	void InternalizeL( RReadStream& aReadStream );
       
   140 	void SetField(const TFieldList aField);
       
   141 	TFieldList Field() const;
       
   142 	void SetOffset(const TInt aOffset);
       
   143 	TInt Offset() const;
       
   144 	void SetLength(const TInt aLength);
       
   145 	TInt Length() const;
       
   146 	void SetCharsetUid(const TUint aUid);
       
   147 	TUint CharsetUid() const;
       
   148 	void SetEncodingType(const TDesC8& aChar);
       
   149 	void SetEncodingType(const TEncodingType aType);
       
   150 	TEncodingType EncodingType() const;
       
   151 	void SetArrayValue(const TInt aValue);
       
   152 	TInt ArrayValue() const;
       
   153 	void SetAddSpace(const TBool atrueFalse);
       
   154 	TBool AddSpace() const;
       
   155 	void SetEncodedLength(const TInt aLength);
       
   156 	TInt EncodedLength() const;
       
   157 
       
   158 public:
       
   159 	friend class CMsvVersion1Version2Converter;
       
   160 	
       
   161 private:
       
   162 	TFieldList		iField; 
       
   163 	TUint16			iOffset;
       
   164 	TUint16			iLength;
       
   165 	TEncodingType	iType;
       
   166 	TUint16			iArrayValue;
       
   167 	TBool			iAddSpace; // A space char needs adding between two adjoining 'encoded-words'
       
   168 	TUint8			iEncodedLength; // This can be used to determine space needed for buffer.
       
   169 	TUint			iCharsetUid; 
       
   170 
       
   171 	};
       
   172 
       
   173 
       
   174 
       
   175 
       
   176 /**
       
   177 CMsvVersion1Version2Converter
       
   178 Converts version 1 message store to version 2 message store. This class converts message part
       
   179 by storing them in version 2 message store. This class can be extended in future by adding API's
       
   180 that will store additional message parts in the database.
       
   181 
       
   182 
       
   183 @internalAll 
       
   184 @released
       
   185 */
       
   186 NONSHARABLE_CLASS (CMsvVersion1Version2Converter): public CBase , public MMsvMessageStoreConverter
       
   187 {
       
   188 public:	
       
   189 
       
   190 
       
   191 	static CMsvVersion1Version2Converter* NewL(CMsvDBAdapter& aDBAdapter,CMsvMessageDBAdapter& aMessageDBAdapter,TDriveNumber aDriveNum,TBool aConversionResume);
       
   192 	~CMsvVersion1Version2Converter();
       
   193 	void ConvertMessageStoreL();
       
   194 private:	
       
   195 	CMsvVersion1Version2Converter(CMsvDBAdapter& aDBAdapter,CMsvMessageDBAdapter& aMessageDBAdapter,TDriveNumber aDriveNum,TBool aConversionResume);	
       
   196 	void ConstructL();
       
   197 
       
   198 	void AddFieldL(TCommonHeaderField aField);
       
   199 	void AddFieldL(HBufC* aFieldName, EFieldType aFieldType);
       
   200 	void StartEMailMessageConversionL(TInt32 aMtm);
       
   201 	void ConvertEMailImapMessagesL(TInt aConvertedMtmArrayIndex);
       
   202 	void ConvertEMailPopMessagesL(TInt aConvertedMtmArrayIndex);
       
   203 	void ConvertEMailSmtpMessagesL(TInt aConvertedMtmArrayIndex);
       
   204 	void CreatePathL(TDes& aMessagePath, TMsvId aId,TMsvId& aOwningId);
       
   205 	TInt ReadEMailMessageHeaderL(TDesC& aMessagePath);
       
   206 	TInt ReadEMailMessageEncodedHeaderL(TDesC& aMessagePath);
       
   207 	TInt ReadEmailMimeHeaderL(TDesC& aMessagePath);	
       
   208 	void CreateEMailHeaderTableStructureL();
       
   209 	void CreateEMailHeaderTableL(const TUid aMtmId);
       
   210 	CArrayFix<TImHeaderEncodingInfo>& EncodingInfo();
       
   211 	void InternalizeL(RMsvReadStream& aReadStream);
       
   212 	TInt GetPropertyValue();
       
   213 	
       
   214 /* start sms APIs */
       
   215 	void InternalizeSmsMessageL(TMsvId aServiceId,TUint32 aMtm);
       
   216 	TBool ReadSmsMessageHeaderL(TDes& aPath);
       
   217 	void InternalizeSmsHeaderL(RReadStream& aStream,TDes16& detailsOfRecipientField);
       
   218 	void InternalizeEmailOverSmsHeaderL(RReadStream& smsHeaderEmailPart);
       
   219 	void CreateSmsHeaderTableL();
       
   220 	void AddSmsFieldL(HBufC* aFieldName, EFieldType aFieldType);
       
   221 	void InitializeL();
       
   222 	void DeAllocateMemory();
       
   223 	TInt FindStream(TUid aUid,TInt &pos);
       
   224 	void FillEmptyEosBufferL();
       
   225 
       
   226 private:
       
   227 	TPtrC iLastErrorMessage;
       
   228 	TBool iResume;
       
   229 	TDriveNumber iDrive;
       
   230 	CMsvDBAdapter& iDBAdapter;
       
   231 	CMsvMessageDBAdapter& iMessageDBAdapter;
       
   232 	RPointerArray<CFieldPair> iTableFieldPairList;
       
   233 	RPointerArray<CHeaderFields> iEmailfieldPairList;
       
   234 	RArray<TUid> iConvertedMtmArray;
       
   235 	RArray<TMsvId> iServiceIdArray;
       
   236 	RArray<TMsvId> iDeleteMessageIdArray;
       
   237 	TConversionResumeStatus iResumeStatus;
       
   238 
       
   239 	CHeaderFields* iSmsHeaderFields;
       
   240 	CHeaderFields* iSmsRecipientAddressFields;
       
   241 	CHeaderFields* iEmailOverSmsAddressFields;
       
   242 
       
   243 	CArrayFix<TImHeaderEncodingInfo>* iEncodingInfo;		
       
   244 	TMsgOutboxBodyEncoding iBodyEncoding;
       
   245 	
       
   246 	RBuf16 iRecipientDetails;
       
   247 	RBuf16 iEmailOverSmsAddress;	
       
   248 	
       
   249 	/*Prepare the store for reading*/
       
   250 	CArrayFix<TPairedTUidHBufC8> *iStreams;
       
   251 	
       
   252 #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)	
       
   253 	friend class CTestSmsMessageV1toV2Converter;
       
   254 	friend class CTestVersion1Version2Converter;
       
   255 #endif
       
   256 	};
       
   257 
       
   258 /**
       
   259 HMsvReadBuffer
       
   260 This class reads information from the stream.
       
   261 
       
   262 @internalAll 
       
   263 @released
       
   264 */
       
   265 NONSHARABLE_CLASS (HMsvReadBuffer) : public TMemBuf
       
   266 	{
       
   267 public:
       
   268 	HMsvReadBuffer(const TDesC8 &aBuf);
       
   269 private:
       
   270 	virtual void DoRelease();
       
   271 	};
       
   272 
       
   273 #endif // __CMSVVERSION1VERSION2CONVERTER_H__
       
   274 
       
   275 
       
   276 
       
   277