harvesterplugins/messaging/smsmms/inc/cmessagemonitor.h
changeset 2 208a4ba3894c
child 9 4a2987baf8f7
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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMESSAGEMONITOR_H
       
    20 #define CMESSAGEMONITOR_H
       
    21 
       
    22 //  INCLUDES 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <msvapi.h>
       
    26 #include "cmessageplugin.h"
       
    27 #include <common.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 
       
    31 class CMessageMonitor : public CActive
       
    32   	{
       
    33 	public:
       
    34 		/**
       
    35 		* NewL
       
    36 		* @return
       
    37 		*/
       
    38 		static CMessageMonitor* NewL(  CMessagePlugin& aMessagePlugin, CMsvSession& aSession );
       
    39 
       
    40 		/**
       
    41 		* Destructor
       
    42 		*/
       
    43 		virtual ~CMessageMonitor();
       
    44 				
       
    45 		/**
       
    46 		 * HandleMsgMovedL handle a moved message
       
    47 		 */
       
    48 		void HandleMsgMovedL( const TMsvId aNewFolderId, 
       
    49 							  const TMsvId aOldFolderId, 
       
    50 							  const CMsvEntrySelection& aSelection );
       
    51 
       
    52 		/**
       
    53 		 * HandleMsgCreatedChangedL handles a new or changed message
       
    54 		 * @param CMsvEntrySelection aSelection list of messages TMsvIds that have changed
       
    55 		 * @param TMsvId aFolderId Folder that contains these changed messages
       
    56 		 * @param MMsvSessionObserver::TMsvSessionEvent aEvent type of event, not used currently
       
    57 		 */	
       
    58 	    void HandleMsgCreatedChangedL( const CMsvEntrySelection& aSelection,
       
    59                                           	        const TMsvId aFolderId,
       
    60                                           	        const MMsvSessionObserver::TMsvSessionEvent aEvent );
       
    61 	    
       
    62 		/**
       
    63 		 * HandleMsgCreatedChangedL handles a deleted message
       
    64 		 * @param CMsvEntrySelection aSelection list of messages TMsvIds that have been deleted
       
    65 		 */		
       
    66         void HandleMsgDeletedL( const CMsvEntrySelection& aSelection );
       
    67         
       
    68 	protected:
       
    69 		/** 
       
    70 		 * inherited from CActive
       
    71 		 */
       
    72 		void RunL();
       
    73 		void DoCancel();
       
    74 		TInt RunError(TInt aError);
       
    75         
       
    76 	private:
       
    77 
       
    78 		/**
       
    79 		* From Constructor
       
    80 		*/
       
    81 		CMessageMonitor(  CMessagePlugin& aMessagePlugin, CMsvSession& aSession );
       
    82 		
       
    83 		/**
       
    84 		* 2nd phase construction
       
    85 		*/
       
    86 		void ConstructL();
       
    87 
       
    88 		/**
       
    89 		 * OverwriteOrAddToQuereL is a helper for MessageItemL. Adds only unique TMsvId's to the processing queue.
       
    90 		 * @param TMsvId aMsvId message to be added to the list
       
    91 		 * @param TCPixActionType aAction action type to be added to the list
       
    92 		 * @param TMsvId aFolderId id of the folder where message is located
       
    93 		 */
       
    94 		void OverwriteOrAddToQuereL(TMsvId aMsvId, TCPixActionType aAction, TMsvId aFolderId);
       
    95 		
       
    96 		/**
       
    97 		 * MessageItemL adds a message to the delayed queue, and schedules the RunL
       
    98 		 * @param TMsvId aMsvId message to be added to the list
       
    99 		 * @param TCPixActionType aAction action type to be added to the list
       
   100 		 * @param TMsvId aFolderId id of the folder where message is located
       
   101 		 */
       
   102 		void MessageItemL(TMsvId aMsvId, TCPixActionType aAction, TMsvId aFolderId);
       
   103 
       
   104 	private:
       
   105 		enum TState 
       
   106 		{ 
       
   107 			EStateNone = 0, 
       
   108 			EStateWaiting 
       
   109 		};
       
   110 		
       
   111 		struct TMessageRecord 
       
   112 		{
       
   113 			TMsvId iMsvId;
       
   114 			TCPixActionType iAction;
       
   115 			TMsvId iFolderId;
       
   116 		};
       
   117 	
       
   118 	private:
       
   119 		// Queue of documents to be indexed
       
   120 		RArray<TMessageRecord> iMessages; 
       
   121 		
       
   122 		// State machine's state
       
   123 		TState iState;
       
   124 
       
   125 		// Timer which is used to delay indexing messages
       
   126 		RTimer iTimer;
       
   127 		
       
   128 		CMsvSession&		iMsvSession;
       
   129 		CMessagePlugin&      iMessagePlugin;
       
   130 	};
       
   131 
       
   132 #endif //  CMESSAGEMONITOR_H