harvesterplugins/messaging/inc/cmessagedatahandler.h
changeset 2 208a4ba3894c
parent 0 ccd0fd43f247
child 3 6832643895f7
equal deleted inserted replaced
0:ccd0fd43f247 2:208a4ba3894c
     1 /*
       
     2 * Copyright (c) 2010 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:  Harvester message plugin
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMESSAGEDATAHANDLER_H
       
    20 #define CMESSAGEDATAHANDLER_H
       
    21 
       
    22 //  INCLUDES 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <msvapi.h>
       
    26 #include "cmessageplugin.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CMmsClientMtm;
       
    30 class CSmsClientMtm;
       
    31 class CClientMtmRegistry;
       
    32 class CSmtpClientMtm;
       
    33 class CPop3ClientMtm;
       
    34 class CImap4ClientMtm;
       
    35 
       
    36 class CMessageDataHandler : public CActive
       
    37 	{
       
    38 public:
       
    39 	/**
       
    40 	 * Construction
       
    41 	 * @return Harvester image plugin
       
    42 	 */
       
    43 	static CMessageDataHandler* NewL(CMessagePlugin& aMessagePlugin,
       
    44 			CMsvSession& aSession);
       
    45 
       
    46 	/**
       
    47 	 * Destruction
       
    48 	 */
       
    49 	virtual ~CMessageDataHandler();
       
    50 
       
    51 	/**
       
    52 	 * Set a item to be indexed.
       
    53 	 * @param TMsvId& aMessageId Id of message
       
    54 	 * @param TCPixActionType aActionType Action type of item
       
    55 	 * @param TMsvId& aFolderId Id of the folder where message is located
       
    56 	 */
       
    57 	void GatherDataL(TMsvId& aMessageId, TCPixActionType aActionType, TMsvId& aFolderId);
       
    58 
       
    59 private:
       
    60 	//From CActive
       
    61 
       
    62 	/**
       
    63 	 * From CACtive.
       
    64 	 */
       
    65 	void DoCancel();
       
    66 
       
    67 	/**
       
    68 	 * From CACtive.
       
    69 	 */
       
    70 	void RunL();
       
    71 
       
    72 	/**
       
    73 	 * From CActive.
       
    74 	 * @param aError Leave code from RunL()
       
    75 	 * @return Error code, KErrNone if error was handled successfully.
       
    76 	 */
       
    77 	TInt RunError(TInt aError);
       
    78 
       
    79 	/**
       
    80 	 * Check if the message is valid and what type it is.
       
    81 	 * @param TMsvId aIdToCheck Id of the message
       
    82 	 * @param TMsgInfo& aMessageType Reference to put message type
       
    83 	 * @return TInt error, if any
       
    84 	 */
       
    85 	TInt IsValidMessageType(TMsvId aIdToCheck, TMsgType& aMessageType);
       
    86 	
       
    87 	/**
       
    88 	 * Launch the next request. 
       
    89 	 */
       
    90 	void HandleNextRequest();
       
    91 
       
    92 private:
       
    93 
       
    94 	/**
       
    95 	 * Private constructor
       
    96 	 */
       
    97 	CMessageDataHandler(CMessagePlugin& aMessagePlugin, CMsvSession& aSession);
       
    98 
       
    99 	/**
       
   100 	 * 2nd phase construction
       
   101 	 */
       
   102 	void ConstructL();
       
   103 
       
   104 	/**
       
   105 	 * Create a message item to be indexed based on the params.
       
   106 	 * @param TMsvId& aMsvId Id of the item to be indexed
       
   107 	 * @param TCPixActionType aAction type of the indexing event
       
   108 	 * @param TFolderId& aFolderId Id of the folder where indexed message is located
       
   109 	 */
       
   110 	 void CreateMessageIndexItemL(const TMsvId& aMsvId, TCPixActionType aActionType, const TMsvId& aFolderId);
       
   111 
       
   112 	 /**
       
   113 	  * Creates general message excerpt
       
   114 	  */
       
   115 	 HBufC* CreateExcerptLC(const TDesC& aFromAddress, 
       
   116 							const CDesCArray& aRecipientArray,
       
   117 							const TDesC& aSubject,
       
   118 							const TDesC& aBodyText,
       
   119 							const TMsvId& aFolderId);
       
   120 	 
       
   121 	 CSearchDocument* CreateSmsDocumentL(const TMsvId& aMsvId, const TMsvId& aFolderId);
       
   122 	 CSearchDocument* CreateMmsDocumentL(const TMsvId& aMsvId, const TMsvId& aFolderId);
       
   123 	 CSearchDocument* CreateEmailDocumentL(const TMsvId& aMsvId, const TMsvId& aFolderId);
       
   124 	 TUint TextFileCharsetL(RFs aFs, RFile aFile);
       
   125 	 void ConvertToUcs2FromUtfL(RFs& aFs,
       
   126 								  TDes& aUcs2Text,
       
   127 								  const TDesC8& aUtfText,
       
   128 								  TUint aMibCharset);
       
   129 	 TBool IsTextUcs2(const TDesC8& aText);
       
   130 	 TBool TextContainsUtf8Bom(const TDesC8& aText);
       
   131 
       
   132 private:
       
   133 	class TMessageItem
       
   134 		{
       
   135 		public:
       
   136 			TMessageItem(TMsvId aMessageId, TCPixActionType aActionType, TMsvId aFolderId)
       
   137 				{
       
   138 				iMessageId = aMessageId;
       
   139 				iActionType = aActionType;
       
   140 				iFolderId = aFolderId;
       
   141 				}
       
   142 			;
       
   143 
       
   144 		public:
       
   145 			TMsvId iMessageId;
       
   146 			TCPixActionType iActionType;
       
   147 			TMsvId iFolderId;
       
   148 		};
       
   149 
       
   150 private:
       
   151 	// Message plugin handle
       
   152 	CMessagePlugin& iMessagePlugin;
       
   153 	// Session Message server session, own
       
   154 	CMsvSession& iMsvSession;
       
   155 	// Messages to be handled
       
   156 	RArray<TMessageItem> iMessageArray;
       
   157 
       
   158 	// Data sources
       
   159 	CClientMtmRegistry*         iMtmReg;
       
   160 	CMmsClientMtm*              iMmsMtm;
       
   161 	CSmsClientMtm*              iSmsMtm;
       
   162 	CSmtpClientMtm*             iSmtpMtm;                 // client for opening smtp
       
   163 	CPop3ClientMtm*				iPop3Mtm;                   // client for opening pop3
       
   164 	CImap4ClientMtm*			iImap4Mtm;                  // client for opening imap4
       
   165 	RFs							iFs;
       
   166 	};
       
   167 
       
   168 #endif // CMESSAGEDATAHANDLER_H
       
   169 // End of File