mds_plat/harvester_framework_api/inc/monitorplugin.h
changeset 58 fe894bb075c2
parent 51 87e65c44ff3a
child 60 79f826a55db2
equal deleted inserted replaced
51:87e65c44ff3a 58:fe894bb075c2
     1 /*
       
     2 * Copyright (c) 2006-2009 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:  Definition of the Monitor plug-in ECom interface.*
       
    15 */
       
    16 
       
    17 #ifndef __MONITORPLUGIN_H__
       
    18 #define __MONITORPLUGIN_H__
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <ecom.h>
       
    22 
       
    23 #include <harvesterdata.h>
       
    24 
       
    25 // FORWARD DECLARATION
       
    26 class CMdESession;
       
    27 class CContextEngine;
       
    28 class CHarvesterPluginFactory;
       
    29 
       
    30 // Uid for this interface
       
    31 const TUid KMonitorPluginInterfaceUid = { 0x20007181 };
       
    32 
       
    33 class TMountData
       
    34 	{
       
    35 	public:
       
    36 	enum TMountType
       
    37 		{
       
    38 		EMount,   // Drive was mounted 
       
    39 		EUnmount, // Drive was unmounted
       
    40 		EFormat   // Drive was formatted
       
    41 		};
       
    42 		
       
    43 	TMountType iMountType;  // See above
       
    44 	TUint32 iMediaID;       // Storage MediaID - TVolumeInfo::iUniqueID
       
    45 	TBuf<2> iDrivePath;     // Drive letter
       
    46 	};
       
    47 
       
    48 /**
       
    49  * Monitor Plug-in ECom interface definition. Monitor plug-in implementation
       
    50  * needs to inherit this class and implement the pure virtual methods which exist 
       
    51  * in this interface. All monitor plug-ins are provided a reference to the Harvester 
       
    52  * server (MMonitorPluginObserver) which hanles the new harvesting requests, open session 
       
    53  * to MdE for DB maintenance operations, pointer to ContextEngine and a pointer Harvester 
       
    54  * plug-in factory.  
       
    55  *
       
    56  * Example:
       
    57  * 
       
    58  * // interface for notifying Monitor plug-in about new files
       
    59  * class MMonitorNotifier
       
    60  *	{
       
    61  *   public:
       
    62  *   	/**
       
    63  *	    * Called when we notice a new file/item
       
    64  *	    *
       
    65  *	    * @param aHarvesterData  Pointer to harvesting related data/harvesting request data
       
    66  *	    *
       
    67  *   	virtual void NewFile( CHarvesterData* aHarvesterData ) = 0;
       
    68  *  }
       
    69  * 
       
    70  * // Monitor plug-in implementation
       
    71  * class CMyMonitorPlugin: public CMonitorPlugin, public MMonitorNotifier
       
    72  *     {
       
    73  *     public:
       
    74  *         TBool StartMonitoring(MMonitorPluginObserver& aObserver, CMdESession* aMdEClient,
       
    75  *				CContextEngine* aCtxEngine, CHarvesterPluginFactory* aHarvesterPluginFactory );
       
    76  *	       TBool StopMonitoring();
       
    77  *	       TBool ResumeMonitoring( MMonitorPluginObserver& aObserver, CMdESession* aMdEClient,
       
    78  *				CContextEngine* aCtxEngine, CHarvesterPluginFactory* aHarvesterPluginFactory );				
       
    79  *	       TBool PauseMonitoring();
       
    80  *         void NewFile( CHarvesterData* aHarvesterData );
       
    81  *
       
    82  *     private:
       
    83  *          MMonitorPluginObserver* iObserver;
       
    84  *          CMyActiveObjectNotifier* iNotifier;
       
    85  *     }
       
    86  *
       
    87  * TBool CMyMonitorPlugin::StartMonitoring(MMonitorPluginObserver& aObserver, CMdESession* aMdEClient,
       
    88  *				CContextEngine* aCtxEngine, CHarvesterPluginFactory* aHarvesterPluginFactory )
       
    89  *     {
       
    90  *     iObserver = &aObserver;  
       
    91  *     
       
    92  *     // Active object which observes the system and notices new files/items in the system
       
    93  *     iNotifier = CMyActiveObjectNotifier::NewL(*this);
       
    94  *     }   	       
       
    95  * TBool CMyMonitorPlugin::StopMonitoring()
       
    96  *     {
       
    97  *	   iNotifier->StopNotifying();	
       
    98  *     }
       
    99  *	       
       
   100  * TBool CMyMonitorPlugin::ResumeMonitoring( MMonitorPluginObserver& aObserver, CMdESession* aMdEClient,
       
   101  *				CContextEngine* aCtxEngine, CHarvesterPluginFactory* aHarvesterPluginFactory )
       
   102  *     {
       
   103  *     // Do what needs to be done when operation is resumed - for example handle
       
   104  *     // events received through callback CMyMonitorPlugin::NewFile during pause. 
       
   105  *     }	      				
       
   106  *	       
       
   107  * TBool CMyMonitorPlugin::PauseMonitoring()
       
   108  *     {
       
   109  *     // Do what needs to be done during pause - for example buffer all events coming 
       
   110  *     // through callback CMyMonitorPlugin::NewFile
       
   111  *     }
       
   112  *
       
   113  * void CMyMonitorPlugin::NewFile( CHarvesterData* aHarvesterData )
       
   114  *    {
       
   115  *	  // Our CMyActiveObjectNotifier notifies us about new file and we notify the Harvester server about it.
       
   116  *	  // Before this CMyActiveObjectNotifier has filled the need data to aHarvesterData like:
       
   117  *	  aHarvesterData->SetEventType( EHarvesterAdd );
       
   118  *    aHarvesterData->SetOrigin( aOrigin );
       
   119  *    iObserver->MonitorEvent( aHarvesterData );
       
   120  *    }
       
   121  */
       
   122 class CMonitorPlugin : public CBase
       
   123   	{
       
   124 	public:
       
   125 		/**
       
   126 		* Creates and constructs a new instance of CMonitorPlugin.
       
   127 		*
       
   128 		* @param aUid  An UID of desired implementation.
       
   129 		* @return A pointer to the new instance of CMonitorPlugin.
       
   130 		*/
       
   131 		IMPORT_C static CMonitorPlugin* NewL(const TUid& aUid);
       
   132 	
       
   133 		/**
       
   134 		* A static method which list all available implementations which satisfy this given interface.
       
   135 		*
       
   136 		* @param aImplInfoArray  On return this contains information about all available implementations.
       
   137 		*/
       
   138 		IMPORT_C static void ListImplementationsL(RImplInfoPtrArray& aImplInfoArray);
       
   139 		
       
   140 		/**
       
   141 		* Destructor
       
   142 		*/
       
   143 		IMPORT_C virtual ~CMonitorPlugin();
       
   144 		
       
   145 		/**
       
   146 		* A pure virtual method which starts the monitoring.
       
   147 		*
       
   148 		* @param aObserver  All events are notified via the aObserver.
       
   149 		* @param aMdEClient  A pointer to MdE client.
       
   150 		* @param aCtxEngine  A pointer to context engine.
       
   151 		* @param aHarvesterPluginFactory  A pointer to harvester plugin factory.
       
   152 		* @return ETrue if success, EFalse if not.
       
   153 		*/
       
   154 		virtual TBool StartMonitoring(MMonitorPluginObserver& aObserver, CMdESession* aMdEClient,
       
   155 				CContextEngine* aCtxEngine, CHarvesterPluginFactory* aHarvesterPluginFactory ) = 0;
       
   156 		
       
   157 		/**
       
   158 		* A pure virtual method which stops the monitoring.
       
   159 		*
       
   160 		* @return ETrue if success, EFalse if not.
       
   161 		*/
       
   162 		virtual TBool StopMonitoring() = 0;
       
   163 		
       
   164 		/**
       
   165 		* A pure virtual method which resumes the paused plug-in.
       
   166 		*
       
   167 		* @param aObserver  All events are notified via the aObserver.
       
   168 		* @param aMdEClient  A pointer to MdE client.
       
   169 		* @param aCtxEngine  A pointer to context engine.
       
   170 		* @param aHarvesterPluginFactory  A pointer to harvester plugin factory.
       
   171 		* @return ETrue if success, EFalse if not.
       
   172 		*/
       
   173 		virtual TBool ResumeMonitoring(MMonitorPluginObserver& aObserver, CMdESession* aMdEClient, 
       
   174 				CContextEngine* aCtxEngine, CHarvesterPluginFactory* aHarvesterPluginFactory ) = 0;
       
   175 		
       
   176 		/**
       
   177 		* A pure virtual method which pauses the plug-in.
       
   178 		*
       
   179 		* @return ETrue if success, EFalse if not.
       
   180 		*/
       
   181 		virtual TBool PauseMonitoring() = 0;
       
   182 
       
   183 	private:
       
   184 		
       
   185 		/**
       
   186 		* Identification on cleanup.
       
   187 		*/
       
   188 		TUid iDtor_ID_Key;
       
   189 	};
       
   190 
       
   191 #endif // __MONITORPLUGIN_H__